使用PHP Xdebug与MAMP的PHP CLI二进制

发布于 2025-02-13 09:09:27 字数 763 浏览 3 评论 0原文

我正在使用MAMP的PHP CLI二进制(即/applications/mamp/bin/php/php7.2.10/bin/php)从终端执行脚本。如何使用Xdebug来通过我执行以这种方式执行的脚本?

到目前为止,我已经读过: 让xdebug与MAMP和Mac一起工作 其中提到了如何启用Xdebug,但仅通过从Web服务器调用脚本来提及。

这是: 安装用于php cli的xdebug 不幸的是,这是在带有XAMPP的Xdebug上,很难推断到MAMP。

是否没有一种简单的方式:

$ phpdebugger phpfile.php

(( 而不是

$ php phpfile.php

,哪个将开始使用文件的调试会话?

如果Xdebug不适合此,是否还有其他程序可以执行此操作?

I am using the PHP CLI binary of MAMP (ie. /Applications/MAMP/bin/php/php7.2.10/bin/php) to execute scripts from the Terminal. How can I use Xdebug to step thru a script that I execute this way?

So far I have read:
https://joshbuchea.com/mac-enable-xdebug-in-mamp/
Getting Xdebug Working with MAMP and Mac
which mentions how to enable xdebug but only through calling the script from a web server.

And this:
Installing Xdebug for PHP CLI
Which is on Xdebug with XAMPP which I unfortunately find difficult to extrapolate to MAMP.

Is there not a simple way like:

$ phpdebugger phpfile.php

(
Instead of

$ php phpfile.php

)

Which will just start the debugging session with the file?

If xdebug is not suitable for this, is there another program to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我也只是我 2025-02-20 09:09:27
  1. 您可以设置-dxdebug.start_with_request = yes

      php -dxdebug.start_with_request = yes you -script.php
     
  2. 或,SET xdebug.start_with_request = yes in php.ini(使用)代码> php -ini 找出哪个文件)。

  3. 或,您可以使用触发环境变量:

      xdebug_trigger =是php your-script.php
     
  1. You can either set -dxdebug.start_with_request=yes:

    php -dxdebug.start_with_request=yes you-script.php
    
  2. Or, set xdebug.start_with_request=yes in php.ini (use php --ini to find out which file that is).

  3. Or, you can use the trigger environment variable:

    XDEBUG_TRIGGER=yes php your-script.php
    
寂寞笑我太脆弱 2025-02-20 09:09:27

我不使用MAMP,但是我用来调试PHP CLI是

export PHP_IDE_CONFIG="serverName=your.servername.com"
php -dxdebug.client_host=xx.xx.xx.xx -dxdebug.mode=debug -dxdebug.start_with_request=yes php_command_here

,显然,在您的代码中添加断点。

I do not use MAMP but what I use to debug PHP CLI is

export PHP_IDE_CONFIG="serverName=your.servername.com"
php -dxdebug.client_host=xx.xx.xx.xx -dxdebug.mode=debug -dxdebug.start_with_request=yes php_command_here

and obviously, add breakpoints to your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文