How to use Xdebugger to debug PHP Built-in Web Server?
Hi all, I have a PHP Built-in Web Server configuration and I cannot get Xdebug to work for setting breakpoints in terms of debugging. I am doing this for a Laravel project. Basically I have installed Xdebug with brew install php54-xdebug for my PHP installation, set remote_enable = On in my php settings. In the PHP Debug settings I have the Xdebug port set to 9000 allowing external connections and in the DBGp Proxy settings I have the IDE key set to my username (which is the default), the host set to local and the port set to 8000 (the port that the built-in web server uses). With this however if I set a break point nothing happens, and I have tried toggling listen for incoming debug sessions and nothing works. Can someone let me know what they did to get this to work?
Thanks,
Darren
Please sign in to leave a comment.
Hi,
Please check out these articles first of all:
http://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+Applications.
If it still don't work, please send here a couple of screenshots and php.ini config.
Hi, below are the screenshots. I install xDebug and set xdebug.remote_emable = On, it uses localhost with port 9000. I also set the DBGp Proxy to use IDE key INTELLIJ, host localhost, and port 9000. Then I installed the Bookmarklets to use that key. I then hit the run for my built in server and hit the Start Listen PHP Debug Connections, set a breakpoint in my code and opened my browser with the bookmarket having the Start hit. Nothing happened. Here are screenshots, what am I doing wrong?
Attachment(s):
Screen Shot 2013-12-17 at 10.39.03 AM.png
Screen Shot 2013-12-17 at 10.38.44 AM.png
Screen Shot 2013-12-17 at 10.38.32 AM.png
Screen Shot 2013-12-17 at 10.38.17 AM.png
Screen Shot 2013-12-17 at 10.38.03 AM.png
1) Do not use Xdebug Proxy -- I doubt you have it installed and running on your computer (I do not think you actually know how it works and what it is for, otherwise you would not attempt to configure it for your environment).
2) Make sure that you have set breakpoint in correct file (or ... that you are executing the correct file). It did not worked for me as well .. simply because I was executing wrong file (different to where I have breakpoints set).
3) Instead of trying this straight away on real complex app, try configuring it for simple script/project first -- it will be easier to figure out what could possibly go wrong
a) Create brand new project with simple script, something like (index.php):
b) Configure and launch your built-in webserver (use slightly different port to avoid confusion between projects, e.g. 8001)
c) Set breakpoints
d) Launch debugging:
If still nothing -- enable xdebug logging (xdebug.remote_log = /path/to/log/file) and see what it will say after each attempt.
In the log I get:
But my breakpoints don't do anything. Its starting to seem that this type of debugging incompatible when running the PHP built in web-server. The breakpoints should work regardless if I am on IntelliJ right?
They should. Unless there was a bug and you still using old version of the PHP plugin. I may only suggest to try that simple test project in actual PhpStorm (latest version is 7.1 build 133.326, released today/yesterday).
It's way to short. This is what I got when script got executed but not breakpoint was set (on purpose). As you can see it's MUCH longer. Your one does not even tries to register any breakpoint or any activity at all.
Possibly you have truncated/edited your log file too much. If so:
1) please post original (non-modified one)
2) provide screenshot of your web-server configuration (for this project) -- also show what command IDE executes when launches it (I must see original file names).
Mine command is:
/usr/local/bin/php -S localhost:8000 -t /Users/darrenlabey/Development/Project/Site/public /Users/darrenlabey/Development/Project/Site/server.php
That server file is very minimal as its the router.
Attachment(s):
Configuration.jpg
And xdebug.log file for this site?
Or is it EXACTLY the same as previous one?
Same as before.
Well .. I'm making my comments purely based on the info YOU have provided. And for me it's either you have edited the log .. or you do have some specific configuration of your OS/file system (symbolic links)?
Based on info from xdebug log and command used to launch PHP's built-in web server, I do see the difference between
/Users/darren/Development/Project/Site/server.php
and
/Users/darrenlabey/Development/Project/Site/server.php
As it stands right now and based on the above, xdebug is trying to debug first one, while your project is located in another folder. This makes original file OUTSIDE of the project (file is not mapped to project files).
You have to remember that IDE works with path as is while xdebug always works with final/resolved paths. If you have symbolic link (e.g. /Users/darrenlabey -> /Users/darren) then you will have to properly setup path mappings in "Preferences | PHP | Servers".
I was simply trying to remove my last name, they are the same paths. The server.php file is a Laravel server routing file for PHP's built in web server to faciliate routing requests to proper controllers. I've followed all of JetBrains' tutorials to try to get this to work on IntelliJ and have come to the conclusion I am using the wrong Run configuration (PHP Built-in WebServer) or that this does not work on IntelliJ. I tried to setup a PHP Web Application configuration with Xdebug selected as the debugger as well as to use the PHP Built-in WebServer configuration when that is ran, thinking because then I had a debug button. I can see the log being actively filled, its just that the breakpoints do not work, and I am on the right file as I have a breakpoint set right before an exit statement.
I gave you a suggestion to try to debug simple project first instead of going to your real one straight away. Did it worked?
Once again -- without real logs I cannot help you here any further. Maybe somebody else can (one of the devs, for example).
Hello!
Configure xdebug to attempt to debug
xdebug.remote_enable = 1