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


so i'm writing api in php, , i'd use full-service debugging tool. i.e., set breakpoints, view stack traces, inspect variables, etc. kind of thing common in compiled languages.

i've checked out xdebug, , after configuring work phpstorm (my ide), disappointed find works when run within phpstorm, not when service real api requests.

to add additional complexity this, api dbs hosted on vagrant instance, although write , edit code on local machine, code being run in virtual machine vagrant environment.

any other way of doing this? or should used along lines of print_r();exit; , rerun request?

use xdebug, , configure properly. can configure work without running code phpstorm quite easily.

xdebug.remote_enable = on xdebug.remote_connect_back = on xdebug.idekey = "vagrant" 

make sure set. then, in phpstorm, there looks phone icon in top right (along rest of debugging , running stuff in toolbar). make sure green (i.e. listening connections).

you can use xdebug set breakpoints. it'll work cli apps if you've set properly. can debug code inside vagrant vms, or on remote servers.

you need research how set ide. ;)

more details: http://www.sitepoint.com/install-xdebug-phpstorm-vagrant/

this may come in handy you: https://www.jetbrains.com/phpstorm/marklets/

and this: https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html

and this: https://confluence.jetbrains.com/display/phpstorm/zero-configuration+web+application+debugging+with+xdebug+and+phpstorm


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -