debugging laravel artisan from PHPStorm with homestead

蹲街弑〆低调 提交于 2019-11-28 19:40:01
Alex

Two things are important:

  1. remote_connect_back can not work in the CLI case because Xdebug can not detect the remote IP when you are in the console
  2. When using homestead / VirtualBox in the NAT network configuration, your development machine (which is running PHPStorm) does not have the IP 127.0.0.1 seen from inside the VM. Instead, it has usually an IP like 10.0.2.2. To find out the correct IP, have a look at your Apache's access.log,

The following worked for me:

php -dxdebug.remote_autostart=on -dxdebug.remote_connect_back=off    -dxdebug.remote_host=10.0.2.2 artisan 
  1. edit If your breakpoints are not hit, you have to set up the folder mappings correctly (as your path in the IDE is different from what the web server sees:

  1. Do export PHP_IDE_CONFIG="serverName=yourservername" in your VM, where yourservername is what you configured in the screenshot under "name"

  2. Add a Php Remote Debug Configuration with an IDE key and the server configured above

  3. And add your IDE key and the remote_host to the VM's XDEBUG-CONFIG

    export XDEBUG_CONFIG="idekey=artisan remote_host=10.0.2.2"

References: http://randyfay.com/content/remote-command-line-debugging-phpstorm-phpdrupal-including-drush

Or, if that all is just too complicated or not working - you can trigger your artisan command via a url (route) using

Artisan::call('whatever:command'); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!