Posts Tagged ‘xdebug’

PHPEclipse + Xdebug + Firefox

October 20, 2010 1 comment

There’s a short but great article about setting up PHPEclipse with Xdebug here:

I really don’t want to forget this one!

Measuring memory usage with XDebug no longer possible (as of 2.0.0 RC4)

November 8, 2009 Leave a comment

For those like me who remember being able to see memory usage in KCacheGrind using Xdebug, well… that’s not possible anymore.

Following the Xdebug’s changelog, the memory profiling has been removed (“Removed support for Memory profiling as that didn’t work properly.”) in 2.0.0 RC4 ([2007-05-17]). Although there’s been a bunch of comments on that feature loss (like here and on the bug tracking system), it doesn’t seem like there’s been any applied patch to fix it. This being said, you might try the proposed patch yourself, if you manage to extract the proposed files (which seem to have disappeared).

You could also using the “trace” feature of Xdebug, but that doesn’t help you see it visually in KCacheGrind.

Well, too sad for all of us who will have to play with memory_get_usage() and memory_get_peak_usage() manually again). Any hope for a fix soon?

Categories: English, Tech Crunch Tags: ,

Instalar Kcachegrind en Ubuntu 8.04

September 17, 2008 Leave a comment

Kcachegrind es una aplicación que nos muestra gráficamente el consumo de tiempo y memoria que un proceso php (función, comando) provoca a un servidor Apache. Aqui una manera facil de instalarlo:

En un terminal ejecutar:

sudo apt-get install kcachegrind
sudo apt-get install php5-xdebug

Configurar estos parametros en el php.ini o en la carpeta /etc/apache2/site-available/sitename

php_admin_value xdebug.profiler_enable 1
php_admin_value xdebug.profiler_output_dir /tmp/kcache

Donde /tmp/kcache es la carpeta donde se guardarán los archivos generados, para luego poder verlos con en Aplicaciones->Programación->Kcachegrind

es necesario que la carpeta /tmp/kcache tenga permisos de escritura

sudo chmod 777 -R /tmp/kcache

Estoy suponiendo que tenemos ya instalado el apache2 y php5 correctamente instalados.

Improving PHP debug speed with XDebug 2.1

Thomas Koch published a nice comment on the XDebug mailing-list recently. It’s about using XDebug 2.1 in a different way to improve your debugging speed by allowing you to automatically open a code editor on XDebug reports.

For the sake of remembering this trick and making is more easily available, I’ve decided to publish it here:


The yet unreleased 2.1 version of XDebug has a nice new feature. The setting


allows you, to provide a printf like format for a link under the filename of
an error message.

So here comes a quick walkthrough on how to open the file from the error
message in (G)VIM:
First we need to tell the browser, in my case firefox, that the link is no web
link, but should be threaten special. We do this with the introduction of the
new protocol “vim://”.

Put this setting in your PHP configuration:


Now instruct firefox which program handles the protocol. Therefor you need to
open the about:config page and add two settings:

network.protocol-handler.external.vim boolean true string

The ff_xdebug_gvim file is a script that parses the link and calls gvim with
the appropriate parameters:

#!/usr/bin/env php5
// cut the vim:// prefix from the input.
$input = substr( $argv[1], 6 );

// split the filename from the line number, separted by ‘@’
// filenames could come in urlencoded
$delimiterpos = strrpos( $input, ‘@’ );
$file = urldecode( substr( $input, 0, $delimiterpos ) );
$line = ( string )( int )substr( $input, $delimiterpos – strlen( $input ) + 1 );

// –remote-silent opens an already running gvim session or creates a new one.
// Replace gvim with
// vim if you like!
system( ‘gvim –remote-silent +’.escapeshellarg( $line ).’ ‘.escapeshellarg( $file ) );

That’s it. Thanks for your patience.

And as usually: Restart your webserver and chmod +x the script.

HOWTO Install xdebug for PHP5 on Ubuntu Feisty

This article is incomplete and was first written in April 2007
for the BeezNest technical website (


Xdebug is an extension for PHP which allows you to track errors and warning in a much more detailed way than what you could get by adding debug messages into your code.

However, installing it on a Linux system when there is no package might represent a little difficulty for the developer-only. This article is only meant to help save a few dozens of minutes from your time by providing the short list of what you need to do on an Ubuntu system to get it rolling.

Technical details

First, you don’t need Xdebug if you don’t have PHP. I assume you will be using PHP5, as it begins now to be the standard on all systems. If you don’t have PHP running, first refer to to know how to install it.

On an Ubuntu system, we first check if a package is available for Xdebug

apt-cache search xdebug

… not much for PHP5 anyway. The idea is that we will then use the second affordable option: install it with PEAR. The PEAR package for PHP offers a command-line tool to download-and-install extensions from the PEAR or PECL websites ( and, respectively). PECL is a bit more restrictive than PEAR, which also means that – in general – you will get more reliable and structured packages from PECL, but you will get more packages in total from PEAR.

You can get information on Xdebug from the PECL website: or you can get installation information from the xdebug website:

Anyway, we want to install the PEAR command-line tool:

sudo apt-get install php-pear

Then we can start using the pecl command-line script to look for the xdebug extension package

sudo pecl search xdebug

Now you can probably see that there are two versions available. The 1.3.2 and the 2.0.0 RC3 at the time of writing this article. The RC3 version is quite stable and offers considerable advantages, so you migh want to install this one. To do this, use the following command

sudo pecl install xdebug-beta

Now depending on what packaged are already installed on your Ubuntu system, you might end up with the following error message: Error: ‘phpize’ failed

This is due to the missing command-line application “phpize” (as you could get from other messages). To install this one:

sudo apt-get install php5-dev

Now you can start again

sudo pecl install xdebug-beta

At the end of the process, you get the following message

install ok: channel://
You should add "" to your php.ini

And that’s what we’re going to do. Edit ”/etc/php5/apache2/php.ini” and look for the section called ”Dynamic Extensions”. On the last line of this section, add the line

Now save the file, close it, and restart Apache

/etc/init.d/apache2 restart

That’s it!

Now you’ll see an additional display (which can be quite long) each time you generate a warning or error message. This message tells you exactly how the script processes through until it gets to the error. If you want to change the way it works now, you’ll have to find it by yourself on the xdebug website (, because this is out of scope here. Have fun!

Categories: English, Tech Crunch Tags: ,
%d bloggers like this: