xDebug stopping at context_get - php

I'm trying to debug my PHP script using xdebug and xdebug_break() method. It start to working and my IDE (PHPDesigner) stop at the break normally, but instantly it stop. Reading the debug.remote_logs file I can check that the last line is:
<- context_get -i 429 -c 0
After that I don't receive a return with a XML data about GET data. So I guess that there live the problem, but how can I fix that?
My php.ini xdebug config is:
[xdebug]
xdebug.remote_mode=jit
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_log=C:\Wamp\logs\xdebug.log
xdebug.idekey=xdebug
I tried to use the XDBG too, and it throw an exception and stop to working. The remote_logs file show the same fail. Using php_xdebug-2.2.0-5.4-vc9.dll.

Before I do post it, I checked out the xDebug last version and it is php_xdebug-2.2.2-5.4-vc9.dll (diff: old 2.2.0, new 2.2.2). Updating that solve my problem and now all works fine. Yey!

Related

PhpStorm won't open xdebug profiler snapshot file

=========================================================
Ignore this post. A much simpler statement of this issue can be found at PHP auto_prepend_file causes xdebug profiler to fail
=========================================================
Original Post (and updates)
When I try to open an xdebug profiler snapshot within PhpStorm using:
menu bar >> Tools >> Analyze xdebug profiler snapshot...
I select the file xDebug created but I'm faced with this error:
Error: Incorrect profiler snapshot format: Incorrect name format
I did not rename the snapshot. It is the default name: cachegrind.out.8008
php.ini
<!-- language:lang-none -->
[xdebug]
zend_extension="php_xdebug-2.5.5-5.6-vc11.dll"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\websites\xdebug"
; xdebug.profiler_output_name= ; Commented out to allow default name
xdebug.idekey=PHPSTORM
Why won't PhpStorm open the snapshot? Should I set a custom xdebug.profiler_output_name option?
Update
I closed all my projects, upgraded from PhpStorm 2017.1.4 to 2017.2, restarted Apache, deleted the old snapshots and created a new one. The new one opens without trouble.
Update 2
Seems that if I run a file from the command line by calling >php script.php, the generated snapshot can be opened. If I run the same file from the browser (meaning I go through the Apache webserver: localhost/script.php) the snapshot cannot be opened.
Update 3
I also notice that when I execute from the browser, I can't delete the snapshot until I force-stop the Apache process. The PHP file I'm profiling has no instructions: just <?php. Below are the two snapshots created:
When executed from the command line (PhpStorm opens this file without problem):
version: 1
creator: xdebug 2.5.5 (PHP 5.6.1-dev)
cmd: C:\path\to\script.php
part: 1
positions: line
events: Time
fl=(1) C:\path\to\script.php
fn=(1) {main}
summary: 0
1 0
When executed from the browser (PhpStorm cannot open this snapshot):
version: 1
creator: xdebug 2.5.5 (PHP 5.6.1-dev)
cmd: C:\path\to\script.php
part: 1
positions: line
events: Time
fl=(2) C:\path\to\script.php
fn=(1)
summary: 0
1 0
Update 4
The culprit is the auto_prepend_file ini setting. I had the following set in Apache Vhosts:
php_value auto_prepend_file "C:\path\to\init.php"
This file is run before Apache executes the script that was called from the browser. When I run the script from the command line, this setting (which is in my Apache Vhosts config) never takes effect so init.php doesn't run. Conversely, if I move the setting to php.ini where it also affects command-line execution, then snapshots generated from the command-line also stop working.
If I remove the auto_prepend_file setting, the generated profiler snapshot can be open without problem in PhpStorm. Of course this isn't a fix since I need the auto_prepend_file to execute for my application to work properly.

Using XDebug with SublimeText on a WAMP server

I have been hacking away at this for hours, and at one point it was actually working on a test page, but I don't know what happened since then because its stopped working. I've been getting this error a lot:
Error: b'Failed loading c:\wamp\bin\php\php5.6.19\ext\php_xdebug-2.4.1-5.6-vc11.dll\n'
Its strange because it definitely is loading the file, when I add this to my php.ini file:
zend_extension = "c:\\wamp\\bin\\php\\php5.6.19\\zend_ext\\php_xdebug-2.4.1-5.6-vc11.dll"
it tells that it is indeed enabled. In the php.ini file I spotted this: In a tutorial I read, the xdebug.ini file appeared in one of those fields: Heres the full settings in my php.ini file:
then check phpinfo() and I now see a section for xdebug:
Also when I run
if (xdebug_is_enabled()) { echo 'its enabled'; }
[xdebug]zend_extension = "c:\\wamp\\bin\\php\\php5.6.19\\zend_ext\\php_xdebug-2.4.1-5.6-vc11.dll"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_log= "C:\\wamp\\tmp\\xdebug.log"
xdebug.profiler_enable=0
xdebug.profiler_output_dir = "C:\\wamp\\tmp"
xdebug.collect_params = 4
xdebug.collect_return = on
xdebug.collect_vars = on
xdebug.show_local_vars = 3
I'll be honest, I have no idea what half of those parameters do. Heres the settings for my sublime project:
"settings":
{
"xdebug":
{
"url": "localhost/xdebug_test"
},
"sublime-view-in-browser": {
"baseUrl": "http://localhost/xdebug_test",
"basePath": "C:\\wamp\\www\\xdebug_test"
}
}
and inside XDebug.sublime.settings I added the URL in there:
"url": "http://localhost/xdebug_test"
Heres the index file in the xdebug_test folder:
but when I start the debugger and launch the browser, it instantly echoes test, and nothing appears in the xdebug console:
It worked on that exact file yesterday, I don't know what could have changed since then.
Is there a way to diagnose whats wrong with it? I don't think so because this isn't just happening in sublime text, heres what happens when I ran a PHP script in the terminal:
EDIT: I just spotted in phpinfo() that the IDE Key is set to PHPSTORM. Thats strange because in the xdebug settings file, its set as this:
"ide_key": "sublime.xdebug",
Could that be the issue? Is there anything I can do here to further diagnose the problem?
Did you try changing the xdebug url in project settings?
"xdebug":
{
"url": "http://localhost/xdebug_test"
}
What if you use this version of dll - https://xdebug.org/files/php_xdebug-2.4.1-5.6-vc11-nts.dll ? Postfix "nts" means "Non-thread-safe".
And of course you can use XDebug wizard to find out which dll version and which settings do you need - https://xdebug.org/wizard.php
I pasted my info into the wizard and heres what I got
I'll give the non threaded version a try.
I figured out the problem, xdebug was connecting to the wrong port. I found the log file in C:/wamp/tmp/xdebug.log and checked out the latest messages, and there were loads of lines saying the same thing:
Log opened at 2016-10-21 16:09:25
I: Connecting to configured address/port: localhost:9001.
E: Time-out connecting to client. :-(
Log closed at 2016-10-21 16:09:26
I suspected the issue was with the port, I checked the php.ini file and it was set to 9001, then I checked Xdebug.sublime-settings and noticed the port was set to 9000. I set the port in php.ini to 9000 and now xdebug is working.
I still don't know why its giving me those errors about not being able to load the extension. Strange because it definitely is loading them.

Drupal 8: Debugging tests with XDebug and PHPStorm - cennot step through

I'm trying to debug my Drupal 8 tests with XDebug, but if I run them with XDebug switched on, I cannot step into the test. I execute the following command:
vendor/bin/phpunit -c core
modules/permissions_by_term/tests/src/Kernel/SelectTermTest.php
PHPUnit reports me here:
"Can't find a source position. Server name 'localhost' doesn't exist."
My settings in the PHP.ini file are looking as follows:
xdebug.remote_enable=true xdebug.profiler_enable=0
xdebug.idekey=PHPSTORM xdebug.max_nesting_level=256
xdebug.remote_autostart=true
Can anybody share here some experience?
I got it to run. I had to do some more settings.
First, create a new PHP Remote Debug under the Run Configurations (The ZeroConfiguration didn't work for me). Define a Server with the name you want (here "TestServer") and enter PHPSTORM as Ide Key.
Also see the Jetbrains documentation: https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+Web+Applications+with+Run+Debug+Configurations
Enable the option "Break at first line in PHP scripts" in under the RUN menu .
It can be possible that you need to override the file mapping. (In my case PHPStorm is not able to detect file mapping automatically) (See: https://www.jetbrains.com/help/phpstorm/10.0/override-server-path-mappings-dialog.html). It's is within same dialog where the server was created.
Start the Remote Debug Session with clicking on the corresponding icon.
Then you should be able to run PHPUnit with this command:
PHP_IDE_CONFIG="serverName=TestServer" XDEBUG_CONFIG="idekey=PHPSTORM" vendor/phpunit/phpunit/phpunit -c YOUPHPUNITXMLCONFIG
Set the PHP_IDE_CONFIG corresponding to your settings.
Set breakpoints where you want to stop.
I hope I could help you.
Nico

Debug php executed from rabbitmq queue with xdebug

I'm trying to debug PHP code executed by a RabbitMQ consumer.
xdebug is working fine in both CLI and http, but it fails when something is executed from a queue. I have set the following trace:
ini_get("xdebug.idekey")
ini_get("xdebug.remote_host")
ini_get("xdebug.remote_connect_back")
ini_get("xdebug.remote_mode").
ini_get("xdebug.remote_autostart")
php_ini_loaded_file()
getenv("XDEBUG_CONFIG")
It prints:
""
localhost
1
req
0
/etc/php5/cli/php.ini
xdebug.idekey=sublime.xdebug
xdebug.remote_host=10.5.223.108
xdebug.remote_connect_back=0
xdebug.remote_mode=req xdebug.remote_autostart=1
So the problem seems to be that it is ignoring the environment variable XDEBUG_CONFIG and is using the values in the cli ini file. I don't have permissions to modify the ini file, and the XDEBUG_CONFIG variable works fine when executing something via CLI.
Any ideas why XDEBUG_CONFIG is being ignored when the code is executed from a queue?
Xdebug and RabbitMQ consumer commands
To make your IDE aware of the connection you need to prefix the command with the environment variable:
XDEBUG_CONFIG="put-here-your-value" php my-script.php

Xdebug interrupts the running of PHP script

I'm using Netbeans 7.3 and xDebugon WAMP. Here is my configuration of xDebugin php.ini:
zend_extension = "c:/wamp/bin/php/php5.4.3/ext/php_xdebug-2.2.3-5.4-vc9.dll"
[xdebug]
xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
If I put a break point on my ajax script, it stops on the break point. If I go line by line with F8 to the end of the script, I get "500 Internal Server Error" as a result. Without the break point, everything is OK. I even get this error on my controller action in Yii. If I go with break point line by line, I get 500 error in the browser. Without the break point, it's working fine. I tried with other versions of xDebug, it's the same.
Any ideas?
500 (Internal Server Error) in phpstorm 9.0 when enabling xdebug breakpoints.
Validate your whatches for php session. Errors in whatches can generate errors in executing php code. Errors disapears when you disable xdebug listening or correct/remove whatches.

Categories