gpt4 book ai didi

laravel - 使用宅基地从 PHPStorm 调试 laravel artisan

转载 作者:行者123 更新时间:2023-12-03 15:13:19 24 4
gpt4 key购买 nike

我设置了 Laravel Homestead。然后我配置了 homestead xdebug.ini 和 PHPStorm 以使调试工作。

这是我在宅基地内的 xdebug.ini

zend_extension=xdebug.so
xdebug.remote_autostart = on
xdebug.remote_enable = on
xdebug.remote_connect_back = on
xdebug.remote_port = 9000
xdebug.idekey = "vagrant"

要开始调试 session ,我遵循的步骤是
  • 在 PHPStorm --> 开始监听连接
  • 在 PHPStorm 中设置断点
  • 在我的浏览器中 --> 使用 XDebug Chrome Helper 或添加到我的 URL ?XDEBUG_SESSION_START=
  • 加载页面

  • 这完美地工作。我的问题是当我在 homestead 命令行中运行 php artisan 时命令然后我无法让它达到我的断点。

    我试过的
  • XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName=server_name" php -dxdebug.remote_host="127.0.0.1" artisan mycommand
  • php -d xdebug.profiler_enable=On artisan mycommand
  • 我也尝试设置xdebug.remote_autostart=On然后 sudo service php5-fpm restart但我的断点仍然没有在 PHPStorm
  • 中被击中

    最佳答案

    有两件事很重要:

  • remote_connect_back无法在 CLI 情况下工作,因为 Xdebug 在控制台中无法检测到远程 IP
  • 在 NAT 网络配置中使用 homestead/VirtualBox 时,您的开发机器(运行 PHPStorm)没有 IP 127.0.0.1从 VM 内部看到。相反,它通常具有像 10.0.2.2 这样的 IP。 .要找出正确的 IP,请查看您的 Apache 的 access.log ,

  • 以下对我有用:
    php -dxdebug.remote_autostart=on -dxdebug.remote_connect_back=off 
    -dxdebug.remote_host=10.0.2.2 artisan
  • 编辑如果没有命中断点,则必须正确设置文件夹映射(因为 IDE 中的路径与 Web 服务器看到的不同:

  • Folder Mappings
  • export PHP_IDE_CONFIG="serverName=yourservername"在你的虚拟机中,yourservername是您在“名称”
  • 下的屏幕截图中配置的内容
  • 添加带有 IDE key 和上面配置的服务器的 Php 远程调试配置
    Debug Configuration
  • 并将您的 IDE key 和 remote_host 添加到 VM 的 XDEBUG-CONFIG
    export XDEBUG_CONFIG="idekey=artisan remote_host=10.0.2.2"

  • 引用文献: http://randyfay.com/content/remote-command-line-debugging-phpstorm-phpdrupal-including-drush

    关于laravel - 使用宅基地从 PHPStorm 调试 laravel artisan,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27936323/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com