Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Debugging grav/php

Started by Muut Archive 11 years ago · 3 replies · 411 views
11 years ago

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).

11 years ago

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
<?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 https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) 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.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1332 9 years ago
Archive · by Muut Archive, 9 years ago
2 923 9 years ago
Archive · by Muut Archive, 9 years ago
2 4053 9 years ago
Archive · by Muut Archive, 9 years ago
1 2931 9 years ago
Archive · by Muut Archive, 9 years ago
3 1109 9 years ago