0

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?

2 Answers 2

3
  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
    
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.