Created
March 16, 2013 11:08
-
-
Save shroukkhan/5175958 to your computer and use it in GitHub Desktop.
debugging remote cli using phpstorm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www.rtuin.nl/2013/01/php-cli-remote-debugging-with-phpstorm-zend-debugger/ | |
--------------------------------------------------------------------------------------------------------- | |
This post aims to give an overview of how to get remote cli debugging working with PhpStorm and Zend Debugger. You can find more detailed information under the links in this article. | |
Some time ago i wanted to debug a PHPUnit test in PhpStorm, debugging PHP scripts using the cli sapi turned out to require some extra effort. | |
The situation is that my project files reside in a virtualbox, and open the project files -via a mounted directory- in PhpStorm. This means that, for normal web debugging, you have to specify some server settings, including the path mapping. | |
Since you work on the server directly, you have to set up a remote debugging connection to your IDE. In his blog post, Kevin Schroeder explains how to do this. | |
You can do this by running the following command, as copied from Kevin’s post: | |
1 | |
export QUERY_STRING="start_debug=1&debug_stop=1&debug_fastfile=1&debug_coverage=1&use_remote=1&send_sess_end=1&debug_session_id=2000&debug_start_session=1&debug_port=10137&debug_host=192.168.0.254" | |
view rawgistfile1.shThis Gist brought to you by GitHub. | |
Don’t forget to change the IP-address and port to the address that you’re IDE is running on. | |
Now there is one more thing you have to do to make PhpStorm understand where the files are, otherwise you still wouldn’t hit those breakpoints. | |
According to this article from the JetBrains team, this can be done by setting the PHP_IDE_CONFIG environment variable to “serverName=name-of-server” where name-of-server is the name as configured in Project Settings -> PHP -> Servers. | |
And oh, make sure your “Listen to Debug connections” button is green! | |
As i work with different projects on the same virtualbox, i have created this small script that you can put in your .bashrc | |
function mybugon() { | |
export QUERY_STRING="start_debug=1&debug_stop=1&debug_fastfile=1&debug_coverage=1&use_remote=1&send_sess_end=1&debug_session_id=2000&debug_start_session=1&debug_port=10137&debug_host=192.168.56.1" | |
export PHP_IDE_CONFIG="serverName=$1" | |
} | |
alias bugon="mybugon" | |
alias bugoff="unset QUERY_STRING" | |
view raw.bashrcThis Gist brought to you by GitHub. | |
You can enable debugging by running: | |
$ bugon server-name | |
And disable by running: | |
$ bugoff | |
------------------------------------------------------------------------------------------------------------ | |
export PHP_IDE_CONFIG="serverName=elastix" | |
QUERY_STRING="start_debug=1&debug_host=192.168.1.2&use_remote=1&debug_port=10137&debug_stop=1&debug_fastfile=1&original_url=http://fake.server" /usr/bin/php Calltivation_log-incoming-into-database.php | |
QUERY_STRING="start_debug=1&debug_host=192.168.70.146&use_remote=1&debug_port=10137&debug_stop=1&debug_fastfile=1&original_url=http://fake.server" /usr/sbin/asterisk start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment