The method is to debug the PHP code executed by the Drush method, the same applies to the normal CLI mode of running PHP program debugging.
1, first need to adjust the CLI mode Xdebug.ini configuration:
sudo vi/etc/php5/cli/conf.d/xdebug.ini
[xdebug]zend_extension= "/usr/lib/php5/modules/xdebug.so" xdebug.coverage_enable=0xdebug.default_enable= 0xdebug.remote_enable=1xdebug.remote_connect_back=onxdebug.remote_host=192.168.xxx.xxxxdebug.remote_port= 9000xdebug.remote_handler=dbgpxdebug.remote_log=/tmp/xdebug.logxdebug.remote_autostart=falsexdebug.idekey= " Phpstorm "xdebug.max_nesting_level=256
One of the
Xdebug.remote_host=192.168.xxx.xxx
Need to change to your host's IP address
2. Create a script file named drush_debug.sh, which sets the variables required for CLI debugging, for convenience, drush_debug.sh directly under the root directory of the Drupal project, and then copy the following contents drush_debug.sh, and save.
#!/bin/bashexport xdebug_config= "Idekey=phpstorm" && export php_ide_config= "Servername=drupalvm.dev" &&drush "[Email protected]"
After saving is complete, use the chmod command to modify the drush_debug.sh so that it has execute permissions.
3, Configuration Phpstorm
About the note:
1). To ensure that the name of the server and the servername of the second step are consistent
2). Tick use path mapping, set absolute path on the server to the directory where the Vagrant virtual machine Drupal project resides.
4. Run Drush command
Enter the directory where Drupal is located, use drush_debug.sh instead of the original drush can be debugged, remember where you need to set a good breakpoint.
5, if the normal CLI debugging, the 2nd step of the
Drush "[Email protected]"
Change into
PHP "[Email protected]"
You can do it.
Because it is very simple, no detailed instructions are made.
6. Instructions for vagrant file synchronization under Windows:
The local path of the Config.vm.synced_folder in Vagrantfile can take the path relative to the file where the Vagrantfile is located, and it is not necessary to install the NTFS plug-in to support the synchronous type to write directly to NFS.
How to Drush scripts in vagrant virtual machines through Xdebug remote debugging in a host