Recently, I was working on a PHP project. I am an ardent fan of IntelliJ Idea and chose to use it for this project as well. Everything went well but I was not able to debug my PHP source code.
After a little bit of googling I found this nice article about debugging PHP code using Idea 10. Since it contained different settings than mine, I modified the instructions to make it work. Here are the modified instructions to debug PHP project in intelliJ Idea 10.
1. Create and copy a file named info.php to your webserver root that contains the following code:
<?php phpinfo(); ?>
3. Open the http://localhost/info.php in a browser to get your PHP configuration.
4. Now view the source of the page in your browser. Copy the entire contents of the source to your clipboard.
5. Goto the XDebug Tailored Installation Instructions and paste your PHP configuration source into the text box then click “analyse my phpinfo() output”.
6. Follow the resulting instructions for adding XDebug to your PHP installation. Once you make those changes, make sure the new section of your php.ini looks like this:
[XDebug]
zend_extension=""
xdebug.remote_enable=true
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.profiler_output_dir="d:\wamp\logs"
7. Open IntelliJ Idea settings by clicking on the wrench icon or going to File->Settings menu. Choose PHP on left navigation tree and set the PHP home along with desired debugger support.
I chose to use XDebug.
8. On the same navigation menu choose servers and enter the details of your web server. Don't forget to mention your web server port. Click on Use path mapping check box and enter the absolute path location of your project files.
9. On the same navigation menu choose Debug and fill the correct value of Debug port. Make sure this entry is same as
xdebug.remote_port in step no 6
.
10. Now go to Run->Edit Configuration menu and add a PHP Web Application configuration. Choose your newly created server from the drop down in Server field. Also fill the value of Start URL field. Generally it is your index page where you want to start the debugging from.
11. That is all. Now you can start debugging your PHP project in IntelliJ Idea. Just apply a break point in your code and click on Debug button and if everything went well, it will open in your default browser and you
will be able to debug it in Idea.
Happy Debugging.
Sphere: Related Content