24

I was able to set up a php web app debugger in PHPStorm by simply tying it to my localhost at a specific port and everything works fine. However for that to work I need to first run this command on the shell:

php app/console server:run --env=dev

This works just fine if I set up breakpoints for browsing the site itself or testing api calls from a browser based rest client like postman

However I'm trying to actually set breakpoints for my mobile app (the mobile app sends http calls to the backend app which is a symfony app). Using the web app configuration doesn't work for this one.

Using this tutorial I was able to incorporate the above command line into PHPStorm, so now I can actually run the code using phpstorm command line tools.

My question is: How can I actually tie the debugger to the command line within PHPStorm? right now when I create a built-in web server in PHPStorm it defaults to using the default php interpreter (i.e If I run the code using the built in web server.. I see this in PHPStorm's console:

/usr/local/Cellar/php54/5.4.28/bin/php -S localhost:8000 -t /project/root/directory

What I want instead is something like this:

php app/console server:run --env=dev -S localhost:8000 -t /project/root/directory

Any idea how to do that?

3 Answers 3

43

You shouldn't create a run configuration at all, just to click on the listen button:

  1. Configure xdebug to attempt to debug every single script (xdebug.remote_autostart = 1 and xdebug.remote_enable = 1).

  2. Use "Phone handle" icon in IDE to start listening for debug connections (e.g. as described in here)

  3. Launch your php code from anywhere -- XDebug will attempt to debug every incoming request.

Here is an hour long webinar about the subject.

bonus

if you're interested in doing the same thing on vi + xdebug, see this answer.

Sign up to request clarification or add additional context in comments.

5 Comments

I believe you forgot one step: Add in xdebug.remote_enable = 1
Thanks a-lot! Now it's clear. If I would find this post before I could save 4h on trying to run the debugger following IntelliJ docs... :(
There's also a good setup post, for Mac Users (but settings apply to all other platforms) at antistatique.net/blog/2013/09/17/….
I tried creating php.ini for the built in server and get error: Fatal error: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND' . I have added extension=php_pdo_mysql.dll so I should not get this error , but I do :(
"You shouldn't create a run configuration at all" - I disagree... the point is to be convenient but also performant. For example, you can run tests in PHPStorm without debugging (default) which makes it fast, but when you need debugging, there's the additional debug button - which is supposed to automatically add the config to enable xdebug for that run. Your instructions work, but are not ideal. To me it feels like a missing feature of PHPStorm.
2

For anyone coming to this post while following all the details but it's still not working.
PHPStorm debugger for (PHP Built-in Server) somehow is problemmetic with the localhost host URL. Just change it to 127.0.0.1 and watch the magic :)

Host-url

Comments

1

I had exactly the opposite experience to Aproram, i.e. it only worked (including honoring breakpoints) when I changed the Host from 127.0.0.1 to localhost. PhpStorm 2025.1.0.1

Server setting

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.