Debugging PHP in Eclipse
Debugging PHP in Eclipse requires 2 parts. Firstly change the php.ini
to include the xdebug sections. All the relevant information can be found in the article Setting up XDebug under XAMPP. Second create an Eclipse run configuration to connect to the remote server which is what this article is for!
You don't have to do this next step but it makes administering your project code easier because you're not forcing all your code to live under the Apache document root. I have different workspaces for different clients so I add an Apache alias to join all the projects together under the same document root. Basically all my code lives in my client folders (along with their accounts etc) and the document root just has virtual directory pointers to those locations.
- From the XAMPP Control Panel, click Apache Config httpd.conf
- Add the following lines after the last
<Directory>
section. This tells Apache about the folder you would like to include.<directory "D:/BigSoftLimited/Clients/Oscorp/workspace/goblin/src/web/"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Require all granted </directory>
- In the alias_module section add the following line to slot the afore mention directory under the document root:
Alias /goblin "D:/BigSoftLimited/Clients/Oscorp/workspace/goblin/src/web"
- The restart Apache.
I'm using Yii for this PHP project but the options should be the same.
- Ensure you have PDT (Eclipse for PHP developers) installed.
- From the menu select: Run->Debug Configurations...
- Highlight the PHP Web Page icon on the left and click the New launch configuration button above.
- Give it a sensible name: Yii Goblin.
- In the Server tab change the Server Debugger to XDebug.
- In the File section Browse and navigate down to the
index.php
file that starts the application. In my case/goblin/src/web/index.php
whereweb
corresponds to the/goblin/
on my web server. - Uncheck Break at First Line.
- If like me you are developing all your projects under the same document root then you will have to uncheck URL -> Auto Generate and enter the entry path to the applications. My Yii project is located at
/goblin/index.php
. You could set it up as/goblin/index.php?r=controller/action
but you will find that you are constantly changing the configuration to test new controllers. - You can leave the rest of the options as is and click Apply followed by Close.
To run
1 comment
Form is loading...