My PHP debugging setup
I am a .NET developer who has been swimming in the PHP pool for the last couple of months.
Spoiled by the IDE, the VS.NET debugger, and strongly typed platforms, I decided to create a PHP development environment that is very similar to my .NET debugging experience.
NOTE. It can be easy to configure PHP debugging in IIS for new PHP applications. However, the steps below break up some very important steps that I thought require debugging in WordPress and Joomla. Follow these steps only if you fail to get debugging work.
Disclaimer: A complete set of steps to complete this installation is highly sought after. I put this together ad hoc in the hope that it will help others who need to create a professional development environment with little experience working on Linux-based systems.
These steps do not guarantee operation and can be very sensitive to the environment settings. I spent a lot of time trying trial and error until I got this job.
Along the way, I have to give credit to a few good online resources that you need to look through to get started. They do not apply to debugging or development tuning. Below I will tell the details.
Walkthrough: Installing XAMPP and WordPress on Windows
Since I am new to posting here, I cannot add multiple links. Just google the following links: - google: tutorials on six articles on web development using -xampp-for-local-wordpress-theme-development
Protecting Your XAMPP Installation
- Google: robsnotebook xampp-builtin-security
DEVELOPMENT SETTING
WAMP Stack vs IIS for PHP:
First, I did not use IIS to host my PHP application. I would like to separate these web servers and use one of the available WAMP Stacks for development against. This allowed me to manage and learn the configuration options that will be used on Apache and Linux. If I were deploying a PHP application on a Windows host, I would choose to configure IIS. Again, it was a choice based on creating similar customized environments with the Linux host.
What is a WAMP stack?
For those unfamiliar, WAMP Stack means the Apache, MySQL, and PHP distribution package that runs on Windows. Other options include LAMP (for Linux), MAMP (for MAC), and others. There are several flavors within the community that provide WAMP stacks for work. I initially found BitNami interesting to work with. However, I was not happy with the control panel used to manage various services on the stack.
Choosing XAMPP for Windows
At the end of the day, I went with a package called XAMPP (Cross Platform Apache, MySQL, PHP, and PERL). The second P in XAMPP provides PERL support, which is absent in other WAMP stacks (WAMPServer, bits, and some others). I also like XAMPP because it has what seems to be a more active community and the stack was very stable for me. Additional distinguishing features of XAMPP for consideration are support for hosting an FTP server, apache-based mail server. The ability to run MySQL and Apachi as a service or run a local application is easily switched at the click of a button.
Configuring XAMPP for development
XAMPP configuration is straightforward. My experience is with the previous release 1.7.3. They just released 1.7.4. Switch to:
- Google: apachefriends xampp-windows
and scroll down until you see the installation links. If you want to work with a release that has matured with some time, you can still find 1.7.3 at the following link:
- Assembly reference: www (dot) apachefriends (dot) org (/) download (php)? xampp-win32-1.7.3.exe
Install XDebug for PHP debugging
This applies to installing PHP on WAMP using Apache or IIS. Choosing the right version of this DLL is not straightforward.
First go to:
- Google: xdebug org download (php)
and view the available versions. The options are not very intuitive for parsing. Follow this guide to understand this: XDebug name distribution: [php_xdebug-2.1.0-5.3-vc6.dll]
- XDebug version 2.1.0 - Compatible with PHP 5.3 - VC6: Use for Apache ver 1 or 2 - VC6 indicates compiled with legacy Visual Studio 6 Compiler - VC9: Use for IIS - VC9 indicates compiled with Visual Studio 2008. - NTS (not listed in the name above) indicates Non Thread Safe. - The version listed is thread safe.
PHP.ini configuration settings
NOTE. Since I have not configured this on IIS, I am not sure which specific settings should be applied. However, this is an online document.
For WAMP / XAMPP:
Locate the file \ php \ php.ini.
- Select the line by adding a half-line to the beginning of the line.
; zend_extension = "php \ ext \ php_xdebug.dll"
Find the [XDebug] section
- Use the settings similar to those listed below and specify the path:
[XDebug]
; General settings
zend_extension = "P: [Fully qualified path] \ xampp \ php \ ext \ php_xdebug-2.1.0-5.3-vc6.dll"
xdebug.profiler_enable = 1;
xdebug.profiler_output_dir = "P: [Fully qualified path] \ xampp \ tmp"
xdebug.profiler_output_name = "xdebug_profile.% p";
xdebug.remote_enable = 1;
xdebug.remote_host = "127.0.0.1";
xdebug.remote_port = 9000;
xdebug.trace_output_dir = "P: [Fully qualified path] \ xampp \ tmp";
; ************ Need for IDE support ************
xdebug.idekey = "vsphp";
;This value can be arbitrary or may require something specific for your IDE.
xdebug.remote_autostart = 1;
xdebug.var_display_max_depth = 5;
Debugging with the IDE
I use 2 IDEs for development in PHP:
I want to love VS.PHP in VS.NET 2010, however this is not the biggest debugging experience. phpDesigner7 was much better for debugging and accessing local variables, intellisense, and using running eval commands during debugging. VS.PHP is so close to great, but you will be disappointed if you have little patience. I still prefer it as my editor of choice, even for PHP.
Regardless of the IDE, most IDEs provide internal debugging support without any of the additional steps listed above. However, these applications will run the php application on a private web server using the specific php.ini settings for the IDE.
I do a lot of custom integration with WordPress, Joomla, and .NET. Therefore, I need the debugger to use the php.ini settings for my various platforms. In order to debug these platforms, I configure my IDEs to run in the main mode of remote debugging. Executing the runtime coordinates of the IDE and the web server using XDebug acting as a broker, and providing the necessary debugging symbols for the IDE debugger.
Setting up the IDE for debugging
The final step is to set up your IDE so that the debugger can connect to the web server.
3 search modes:
- PHP-CGI: P: [Fully Qualified Path] \ xampp \ php \ php-cgi.exe
- PHP.INI: P: [Fully Qualified Path] \ xampp \ php \ php.ini
- Listen port: 9000
Different IDEs may mark these settings differently and require additional settings. They should be the most important for the search.
NOTE. For debugging, use [php \ php-cgi.exe], not [php \ php.exe]. Php-cgi.exe is required to run php.exe on Windows.
Hopefully you will start by attaching your IDE to the web server, setting breakpoints and much more for debugging strings.