Xdebug laravel工匠命令

Jam*_*kby 7 php xdebug command-line-interface laravel artisan

我经常使用xdebug来调试应用程序,我已经构建了一个laravel应用程序,它可以上传一个csv,将数据插入到数据库中,并将id输入到作业队列中.

我写了一个工匠命令,通过cron运行,然后对这些数据做一些事情.

Xdebug适用于通过浏览器访问该站点,但从cli运行时它不会破坏断点.

我运行php5-fpm.我的文件/etc/php5/fpm/php.ini,并/etc/php5/cli/php/ini 都包含以下设置:

zend_extension=/usr/lib/php5/20121212/xdebug.so 
xdebug.remote_enable = 1 
xdebug.idekey = 'dev_docker' 
xdebug.remote_autostart = 1 
xdebug.remote_connect_back = {{my host ip}} 
xdebug.remote_port = 9000 
xdebug.remote_handler=dbgp
Run Code Online (Sandbox Code Playgroud)

然后我运行artisan命令

php artisan jobqueue::process --batch-size=10 --sleep=10
Run Code Online (Sandbox Code Playgroud)

我知道命令正在运行 - > info('text')显示在终端中

谁知道我错过了什么?

小智 13

如果您使用的是 XDebug 版本 3,请尝试:

php -dxdebug.mode=debug -dxdebug.client_host=host.docker.internal -dxdebug.client_port=9003 -dxdebug.start_with_request=yes artisan your:command
Run Code Online (Sandbox Code Playgroud)

更新2023-08

我正在使用 xDebug v3.2.1,php v8.2。xdebug.ini如果您不想每次都编写这些长命令,请将这些行添加到文件中。/etc/php/8.2/modes-available/xdebug.ini

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.start_with_request=yes
Run Code Online (Sandbox Code Playgroud)

  • 这就是我所需要的: php -dxdebug.mode=debug -dxdebug.start_with_request=yes artisan my:command (8认同)

bor*_*ris 8

也许这会帮助某人。

简而言之,我遇到了同样的问题,但是我并没有获得公认的答案。我的解决方案是从命令行运行此命令:

php -dxdebug.remote_enable=1 -dxdebug.remote_autostart=on -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 artisan my:command
Run Code Online (Sandbox Code Playgroud)

  • 您应该添加 `dxdebug.remote_autostart=on` (3认同)

Fur*_*gas 1

根据xdebug.remote_connect_back文档,它用于$_SERVER['REMOTE_ADDR']获取调试主机。我想在 CLI 中你必须使用xdebug.remote_host代替。