THESE INSTRUCTIONS ARE EXPERIMENTAL
Please post any problems you have using these instructions to the PHP forum
Contents |
Basic Setup
- Install Apache if necessary
- In Studio's Servers view add a new Apache server into the list, pointing the executable to the Apache httpd executable
Setting up PHP on Apache
- Locate the the httpd.conf in your Apache install dir (usually under the conf directory).
- Open the file and adding the following lines, with the paths modified to fit your system:
#load the php main library Loadfile "C:\php\php5ts.dll" #load the sapi so that apache can use php LoadModule php5_module "C:\php\php5apache2_2.dll" #set the php.ini location PHPIniDir "C:\php" #Hook the php file extensions AddHandler application/x-httpd-php .php AddHandler application/x-httpd-php-source .phps
Setting up XDebug in php.ini
- Locate your php.ini file (same path as you defined in the httpd.conf).
- Open the file and add the following lines (again, paths should be modified according to your system):
[XDebug] ;Hook the XDebug zend_extension_ts=C:\php\ext\php_xdebug-2.0.3-5.2.5.dll xdebug.remote_enable=1 xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler="dbgp"
Verify the installation
- Restart Apache
- Create a PHP file named phpinfo.php in Apache's htdocs directory containing something simple, such as <?php phpinfo(); ?> to the file and save it.
- Open this file in your web browser using Apache: "http://localhost/phpinfo.php" and you should see the standard phpinfo output.
- Verify that the XDebug was loaded by locating the note at the bottom of the first section. It should say something like: "with Xdebug v2.0.3, Copyright (c) 2002-2007, by Derick Rethans"
Aliasing to your PHP project
Assuming that you already have a PHP project set up in your Aptana Studio, you need to create an Apache Alias pointing to that project. It is crucial that you will name your alias exactly like you named your project
For example, a project named RemoteDebugTest should have this Alias setting in the httpd.conf:
Alias /RemoteDebugTest C:\Eclipse\workspace\RemoteDebugTest <Directory C:\Eclipse\workspace\RemoteDebugTest> Order allow,deny Allow from all </Directory>
After saving httpd.conf, restart Apache to make your changes effective.
Creating a launch configuration
- Place one or more breakpoints in the file to be debugged, which must exist in the project you aliased for Apache
- Open the launch configuration dialog by accessing the debug shortcut (or by using the action from the menu Run -> Open Debug Dialog)
- Create a new PHP Web Page debug configuration
- Verify that the XDebug debugger is selected and that you use the properly configured Apache server
- Select Use specified script and locate the file you wish to debug
- Make sure that the Studio XDebug client is listening on port 9000. The port is set on the Preferences panel Aptana -> Editors -> PHP -> Debug, and the XDebug listen port should be the same one you set in php.ini.
- Start debug
At this point a debug session is initiated. A browser is opened and, in case your code hits the breakpoint, you'll see that the debug stack is paused on the line in the source code.
Notes
- The browser is opened with the URL to the aliased file with the added query string of ?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=some_number, similar to ?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=12276559562343
- The number at the end of the URL changes for each launch
- Once you resume execution, even if there are no more breakpoints, the launch in your debug view is still alive. It's just waiting for more requests triggered by browser actions.
- For example: You have a form to debug. You can do so by starting a debug session and placing a breakpoint on the right spot to catch the form input after the user hits the submit button. The debug session will be terminate only when you hit the stop button on that.