mercredi 22 avril 2015

How to debug apis in PHP (without using var_dump();die();)

So I'm writing an api in php, and I'd like to use a full-service debugging tool. i.e., set breakpoints, view stack traces, inspect variables, etc. This kind of thing is very common in compiled languages.

I've checked out xdebug, and after configuring it to work with phpstorm (my IDE), I was disappointed to find that it only works when I run from within phpstorm, not when I actually service real api requests.

To add additional complexity to this, the api dbs are actually hosted on a vagrant instance, so although I write and edit code on my local machine, the code being run is in a virtual machine vagrant environment.

Any other way of doing this? Or should I just get used to something along the lines of print_r();exit; and rerun the request?

Aucun commentaire:

Enregistrer un commentaire