[xdebug-general] xdebug doesn't work when PHP script is launched with exec()

From: Voxen <voxen06[@]gmail.com>
Date: Sat, 22 Oct 2011 11:54:03 +0200

Hi

I have xdebug up and running when debugging through Netbeans IDE on Mac OSX Lion.

I can also debug a CLI script from the shell like this:
$ export XDEBUG_CONFIG="idekey=netbeans-xdebug"
$ /usr/bin/php myscript.php

However I can't make the debugger stop on a xdebug_break() line if I start a PHP script from another script using exec(), like this:

<?php
exec('/usr/bin/php myscript.php');
?>

I also tried:

<?php
shell_exec('export XDEBUG_CONFIG="idekey=netbeans-xdebug"; /usr/bin/php myscript.php');
?>

And I even tried to run a batch file like this:
$ nano /usr/bin/php-xdebug.sh
-> export XDEBUG_CONFIG="idekey=netbeans-xdebug"
-> /usr/bin/php $1

<?php
exec('/usr/bin/php-xdebug.sh myscript.php');
?>

As I said, if I open a Terminal window and type:
$ export XDEBUG_CONFIG="idekey=netbeans-xdebug"
$ /usr/bin/php myscript.php
then it works, the debugger stops at the "debug_break()" line of myscript.php.

Why it doesn't work through PHP's exec?
Is there another way to make it work?

Thanks for your help!
Received on Sat Oct 22 2011 - 10:54:06 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST