我有一个PHPUnit测试,使用curl_exec
调用一个API。如果我在测试中设置了一个断点,它就可以工作,但是当我在curl_exec
调用的API类上设置断点时,这并不是在断点上停止。
我的xdebug配置:
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "/var/www/html/xdebugProfiler"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = 1
xdebug.remote_mode=req
xdebug.remote_connect_back=1
xdebug.remote_port = "9000"
xdebug.trace_output_dir = "/var/www/html/xdebugProfiler"
xdebug.max_nesting_level = 200
xdebug.idekey = "PHPSTORM"
我已经在我的PhpStorm设置中将Max同时连接设置为10。
on curl_exec:
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_COOKIE,"XDEBUG_SESSION=PHPSTORM");
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_FAILONERROR,true);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLINFO_HEADER_OUT,true);
curl_setopt($curl, CURLOPT_TIMEOUT,2);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$requestHeaders[] = "Cache-Control: no-cache";
$requestHeaders[] = "Pragma: no-cache";
curl_setopt($curl, CURLOPT_HTTPHEADER,$requestHeaders);
$response = curl_exec($curl);
我不知道我能做什么,把它付诸实践。 :/希望有人能帮助我。
xdebug log:
Log opened at 2017-09-28 21:54:12
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Checking header 'REMOTE_ADDR'.
W: Remote address not found, connecting to configured address/port: 192.168.100.113:9000. :-|
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/5.4_maintenance/tests/bin/phpunit.phar" language="PHP" xdebug:language_version="5.6.19" protocol_version="1.0" appid="7864" idekey="16315"><engine version="2.4.0"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2016 by Derick Rethans]]></copyright></init>
<- feature_set -i 1 -n show_hidden -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="show_hidden" success="1"></response>
<- feature_set -i 2 -n max_depth -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>
<- feature_set -i 3 -n max_children -v 100
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="max_children" success="1"></response>
<- feature_set -i 4 -n extended_properties -v 1
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="4" status="starting" reason="ok"><error code="3"><message><![CDATA[invalid or missing options]]></message></error></response>
<- status -i 5
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="5" status="starting" reason="ok"></response>
<- step_into -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="6" status="break" reason="ok"><xdebug:message filename="file:///var/www/html/5.4_maintenance/tests/bin/phpunit.phar" lineno="3"></xdebug:message></response>
<- breakpoint_set -i 7 -t line -f file:///var/www/html/5.4_maintenance/application/controllers/favoritesController.php -n 15
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="78640001"></response>
<- stack_get -i 8
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="8"><stack where="{main}" level="0" type="file" filename="file:///var/www/html/5.4_maintenance/tests/bin/phpunit.phar" lineno="3"></stack></response>
<- run -i 9
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="9" status="stopping" reason="ok"></response>
<- run -i 10
Log closed at 2017-09-28 21:54:16