=========================================================
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.
Related
I'm getting the error when trying to access any page running on the builtin php webserver (including just a phpinfo):
Fatal error: Could not delete queued timer in Unknown on line 0
This is the command I am using to run the server
~/php-win$ wine php.exe -S localhost:8080
Here is the content of my php.ini file, which I am assuming is the cause of the error because of the Unknown on line 0 part.
Through trial and error I have discovered that if I comment out the max_input_time value then pages will load fine however the error shows up at the bottom of the page instead. See the below image:
I also had the exact same issue when attempting to set up an EasyPHP server as well (through wine also).
The only other question I could find on this error was this question, however this is happening when I run any file through the built-in webserver, including a blank file.
Also, I am using PHP 7.1.3
Edit your php.ini and put the location of extension folder , the folder named ext inside your php folder
php.ini
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "/media/viney/01D58852BCA3B9C0/UwAmp/bin/php/php-7.0.3/ext"
Then I enable a few extensions in php.ini
php.ini
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
Now if I run php, extenions get loaded
viney#Notebook:/media/viney/01D58852BCA3B9C0/UwAmp/bin/php/php-7.0.3$ wine php -S localhost:8080
PHP 7.0.3 Development Server started at Mon May 4 09:28:07 2020
Listening on http://localhost:8080
Document root is Z:\media\viney\01D58852BCA3B9C0\UwAmp\bin\php\php-7.0.3
Press Ctrl-C to quit.
I am trying to use XDebug with PHP and VS Code on Windows. I have successfully installed XDebug because it shows up in the phpinfo() page.
When I attempt to use XDebug on VS Code, I get this error:
DEBUG Checking PHPLS_ALLOW_XDEBUG
DEBUG The xdebug extension is loaded (2.7.1)
DEBUG Process restarting (PHPLS_ALLOW_XDEBUG=internal|2.7.1|0|*|*)
DEBUG Running C:\Users\***\Documents\Applications\php-7.3.4-nts-Win32-VC15-x64\php.exe -n -c C:\Users\***\AppData\Local\Temp\AF9E.tmp c:\Users\***\.vscode\extensions\felixfbecker.php-intellisense-2.3.10\vendor\felixfbecker\language-server\bin\php-language-server.php --tcp=127.0.0.1:50124 --memory-limit=4095M
DEBUG Checking PHPLS_ALLOW_XDEBUG
DEBUG Restarted (64 ms). The xdebug extension is not loaded
[Info - 11:04:12 AM] 1 files total
[Info - 11:04:12 AM] Indexing project for definitions and static references
Parsing file:///c:/xampp/htdocs/blank/blank.php
[Info - 11:04:12 AM] Indexing project for dynamic references
[Info - 11:04:12 AM] 0 Packages
[Info - 11:04:12 AM] All 1 PHP files parsed in 0 seconds. 148 MiB allocated.
I just had this issue too and looking at the configuration that was being provided (in the original example above it's C:\Users\***\AppData\Local\Temp\AF9E.tmp), I found that the zend_extension line had been commented out.
ie. it appears as this in the .tmp file:
;zend_extension=php_xdebug-2.7.2-7.3-vc15-nts-x86_64.dll
The semicolon being the commenting character.
A little experimentation showed that it was commenting it out itself based on the filename. I renamed the DLL to totallynotphpdebgr272.dll and set that as the zend_extension in php.ini. After that change it no longer commented that line in the generated .tmp file and I was able to start debugging php successfully in vscode.
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
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
I just installed wamp and the latest version comes with webgrind, but i cannot figure out how it works.It says
Select a cachegrind file above
And thats all.
Webgrind is a parser/viewer for a profiling file format called cachegrind. The PHP extension Xdebug can (among other very useful things) generate these. For webgrind to work, Xdebug needs to be installed and enabled.
Make sure Xdebug is installed and working (see the Xdebug docs for info on how to do that)
Have Xdebug generate a profiling report by requesting a local PHP file
Load webgrind in the browser and select a file in the popup-menu at the top
Press update, and hopefully everything should work
The wiki on Google Code has more on configuring webgrind.
1) Download XDebug from their download page.
2) Put all DLL files in your PHP extension directory: C:\wamp\bin\php\php5.x.x\ext
3) Add the following line in your php.ini file located in C:\wamp\bin\php\php5.x.x:
zend_extension = c:\wamp\bin\php\php5.3.0\ext\php_xdebug-2.1.0-5.3-vc6.dll
4) Add also the following section to your php.ini (search for the [xdebug] section first to make sure it does not exist yet):
[xdebug]
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "c:\wamp\www\webgrind\tmp"
xdebug.profiler_output_name = cachegrind.out.%t.%p
5) Restart Wamp and verify that the extension was loaded. To do so, add a file pi.php in C:\wamp\www\ and put the following code in it:
<?php
phpinfo();
?>
6) Check the output by opening your browser at http://localhost/pi.php and search for XDebug.
7) Download Webgrind from their download page and extract in in your www folder.
8) Edit the config.phpfile located in C:\wamp\www\webgrind\ to change the storage directories:
static $storageDir = 'c:\wamp\www\webgrind\tmp';
static $profilerDir = 'c:\wamp\www\webgrind\tmp';
9) In the Webgrind directory where you have extracted the code, add an .htaccess file and put this content in it to avoid webgrind from profiling itself:
php_flag xdebug.profiler_enable 0
10) Rerun the http://localhost/pi.php script to generate some profiling data.
11) Open your browser with http://localhost/webgrind to display the results. Do not forget to click the Update button!
This answer is based on an answer provided by Jacob Moen. You can view the original source here.
It is good to watch if the application becomes SLOW, had problems with
it because of the settings of Cachegrind.
Good luck!
My settings are Wamp 2.4, Apache 2.4, PHP 5.4 and MySQL 5.6
[Portugues pt_BR]
É bom prestar atenção se a aplicação se tornar LENTA, tive problemas com isso por causa das configurações do cachegrind.
Boa sorte!
Minhas configurações são Wamp 2.4, Apache 2.4, PHP 5.4 e MySQL 5.6
Update the PHP.INI with these parameters
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
RESTART ALL SERVICES
this should be work.
You don't have to do much....
I just edited the line to be
xdebug.profiler_enable = 1
Thats all buddy. Totally works!