Debugging grav/php

I’m new to PHP and debugging it’s code. I find debugging and stepping through the code the easiest way to learn a large source tree.
I figured out how to debug and step through the execution of bin/gpm or bin/grav with phpstorm. But how to debug cd grav ; php -Slocalhost:8000 from within phpstorm is still a mystery to me. I’m not interested in running a whole LAMP stack neither in order to debug small things in grav.
What I’d like is start the local server from PHP, set some breakpoints and have them triggered, step from there, examine some variables (just for example a breakpoint inside a plugin’s code or system/src/page/pages.php) when from my browser I click a link.
If you think I should use another IDE than phpstorm because that’s easier, that’s fine (currently using phpstorm 9, 1 month trial).
Putting me on the road by pointing to a good URL is fine too. I looked inside phpstorm’s documentation but I just don’t manage to get it to work (googling brought me to those pages).

If you are debug and step through code via /bin/grav and bin/gpm then you have installed xdebug in your PHP. If you have done that then, it probably should just work when you run php via the command line with the -S to start the server. You can probably double check by creating a simple info.php file with:

<?php phpinfo();

This should give you lots of information about PHP, including whether or not xdebug is loaded. If it is loaded, then all you need do at that point is just enable xdebug via the browser (I use and then turn on listening.

BTW, I’ve never done this via the PHP built-in server. I’ve always had an apache setup when I’m doing debugging. If you are going to go to the trouble of getting debugging working, it probably makes sense to have a real development environment set up. If you’re on Mac, I have a very thorough guide for getting apac he/php setup in the blog. Also there are simple apps like MAMP, XAMPP, Uniform, etc that are an all-in-one solution.

Thanks. I found how to put all pieces together. I described it in a small blog:
I hope it might help others as well (still avoiding a whole apache set-up and all its configuration woes :slight_smile:

nice blog post :slight_smile: