views:

74

answers:

1

I would like to update my local working environment to be stricter in an effort to improve my code. I know that my code is okay, but as with most things there is always room for improvement.

I use XAMPP on my local machine, for simplicities sake Apache Friends XAMPP (Basic Package) version 1.7.2 So I've updated my php.ini : error_reporting to be E_ALL | E_STRICT to help with the code standard. I've also enabled the XDebug extension zend_extension = "C:\xampp\php\ext\php_xdebug.dll" which seems to be working, having tested some broken code and got the nice standard orange error notice.

However, having read this question, http://stackoverflow.com/questions/133686/what-is-the-best-way-to-profile-php-code and enabled the profiler, I cannot seem to create a cachegrind file.

Many of the guides that I've looked at seem to think you need to install XDebug in XAMPP which leads me to think they are out of date, as XDebug is bundled with XAMPP these days.

So I would appreciate it if anyone can help point me in the right direction with both configuring XDebug to output grind files, and or just a great set of default settings for the XDebug config in XAMPP. Seems there is very little documentation to go on.

If people have tips on integrating these tools with Netbeans, that would be awesomesauce.

I'm happy to get suggestions on other things that I can do to help tighten up my php code, both syntactically and performance wise

Thanks, and apologies for the rambling question(s)!

Ninja edit

I should menion that I'm using named vhosts as my Apache configuration, which I think is why running XDebug on port 9000 isn't working for me. I guess I'd need to edit my vhost to include port 9000

A: 

If you always want to run the profiler:

xdebug.profiler_enable  = 1

else if you want to selectively switch the profiler on (a good thing), use:

xdebug.profiler_enable_trigger  = 1

If you're triggering, you'll need to using the XDEBUG_PROFILE GET/POST parameter, or send a cookie with the name XDEBUG_PROFILE. There are browser add-ons to help; For Firefox I use Xdebug Helper, but as it seems to have disappeared you could try easy Xdebug.

I found that the default output dir didn't work, so try setting it yourself:

xdebug.profiler_output_dir  = /home/deebster/php/profiler

Remember to set the directory's permissions to allow Apache to create files if you don't use /tmp

Deebster