Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
调用exec(';PHP…';)时,PHP调试器挂起_Php_Debugging_Netbeans_Xdebug - Fatal编程技术网

调用exec(';PHP…';)时,PHP调试器挂起

调用exec(';PHP…';)时,PHP调试器挂起,php,debugging,netbeans,xdebug,Php,Debugging,Netbeans,Xdebug,我有一个PHP脚本,在这个脚本中,我在另一个PHP脚本上调用exec()。这运行得非常好,但在NetBeans中使用XDebug调试器时会挂起。这给我带来了各种各样的问题,因为我无法调试整个应用程序 以下是一个简单的例子: test1.php <?php $output = array(); $status = 0; exec('echo "Running inside test 1"', $output, $status); exec('php ' . __DIR__ . '/test

我有一个PHP脚本,在这个脚本中,我在另一个PHP脚本上调用exec()。这运行得非常好,但在NetBeans中使用XDebug调试器时会挂起。这给我带来了各种各样的问题,因为我无法调试整个应用程序

以下是一个简单的例子:

test1.php

<?php

$output = array();
$status = 0;
exec('echo "Running inside test 1"', $output, $status);
exec('php ' . __DIR__ . '/test2.php', $output, $status); // Debugger hangs here

var_dump($output);
var_dump($status);
?>

之所以发生这种情况,是因为当您执行第二个脚本时,xdebug已经很忙,所以内部脚本会暂停,外部脚本的执行无法继续

要解决这个问题:

  • 注释php ini中的xdebug设置,并检查环境变量xdebug_CONFIG不包含任何内容
  • 使用xdebug参数启动主脚本(php-dxdebug.remote\u enable=1-dxdebug.remote\u mode=req-dxdebug.remote\u port=9000-dxdebug.remote\u host=127.0.0.1)
  • 不带xdebug参数的exec第二个脚本:exec('php script.php')
  • 要调试内部脚本,请在不使用xdebug的情况下启动第一个脚本,并使用xdebug执行,反之亦然

    <?php 
    echo "Running inside test 2" . PHP_EOL;
    ?>