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 have a new computer, Dell Inspiron 17 7000 Series. This is Laptop :
i7-6500U CPU # 2.50GHz, 2601 MHz
16 Go RAM
512 Mo SSD
Windows 10, Wampserver 3.0.6 and PHP7 and OPCache
But with Symfony (New app, juste 3 slim controllers), my app is terribly slow ... 30 seconds :/
This is my php.ini var :
- realpath_cache_size = 12288K
- realpath_cache_ttl = 1800
- opcache.max_accelerated_files=60000
Can you help me ?
Most probably it's because of enabled XDebug.
It happens with many PHP applications on Windows, not only with Symfony.
As discussed here, try to disable "remote_autostart" and "profiler_enable" modes:
xdebug.remote_autostart = 0
xdebug.profiler_enable = 0
Or even comment out line where XDebug is enabled, if above does not help:
;zend_extension = "/absolute/path/to/your/xdebug-extension.so"
=========================================================
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.
PHP runs so slowly on my Windows desktop that phpMyAdmin takes minutes to open a database. Here’s a comparison of the time to run a simple PHP test program:
Windows 8.1 machine running XAMPP: 3597 ms
iPage shared hosting: 65 ms
A2Hosting shared hosting: 26 ms
Here’s the test program…
<?php
$rStartTime = microtime(true);
$countTo = 100000;
$a = 0;
//$countTo = $countTo * 100;
for ($x = 0; $x <= $countTo; $x++) {
$a = sqrt(pow($x, 2));
}
$rMs = floor((microtime(true) - $rStartTime) * 1000);
echo 'timer done, countTo=' . $a . ' ms=' . $rMs;
The test program is run without debugging, by entering "http://localhost/timer.php" into Firefox.
The local machine is normally blazing fast. It’s running…
Windows 8.1
XAMPP 1.8.3 (control panel v3.2.1)
Apache 2.4.4 (latest is 2.4.20)
PHP 5.5.3
Antimalware = Windows Defender
IDE = PHPStorm 10.0.2
What's making PHP run so slowly?
I found the problem was Xdebug in xampp\php\php.ini. Here're the results of trying many solutions found around the web:
Run XAMPP as adminisrator and restart server: 3617 ms
In xampp/apache/conf/httpd.conf, replace localhost with 127.0.0.1 and restart server: 3639 ms
In Windows/System32/drivers/etc/hosts, add “127.0.0.1 127.0.0.1” & “127.0.0.1 localhost” and restart Windows: 3960 ms
In Windows/System32/drivers/etc/hosts, un-comment “127.0.0.1 localhost” and restart Windows: 3659 ms
In php.ini, uncomment zend_extension = "C:\xampp\php\ext\php_eaccelerator_ts.dll" and restart server: 3643 ms
In php.ini, set xdebug.remote_enable=0: 3598 ms
In php.ini, set remote_host="localhost": 3593 ms
In php.ini, set xdebug.profiler_enable=0: 249 ms
In php.ini, comment out all Xdebug statements: 27 ms - Success!
The sad part is, I make mistakes and need Xdebug :-(
I solve my problem with xdebug idekey setting (xdebug.idekey="xdebug1"), and chrome extension xdebug helper (https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc)
*Dont forget to disable remote_autostart (xdebug.remote_autostart=0)
Only activating debug (xdebug) by request, using idekey setting, so if debug not needed php processing can be faster/normal, tonggle by button with chrome extension
I'm using xampp 1.8.3 on windows 10 64bit,
i use custom idekey, xdebug.idekey="xdebug1", same with xdebug helper setting
[XDebug]
zend_extension = "E:\xampp183\php\ext\php_xdebug.dll"
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "E:\xampp183\tmp"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart=0
xdebug.idekey="xdebug1"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.trace_output_dir = "E:\xampp183\tmp"
xdebug.remote_log="E:\xampp183\tmp\xdebug\xdebug.log"
Now breakpoint/debug activated only if session is requsted via xdebug helper
I excluded my website folder and my xampp folder in Windows Defender and things were solved here.
I Had the same problem with xampp, and the problem was WINDOWS DEFENDER, if you disable the windows defender protection, xampp is faster (normal speed), Also you can search the xampp folder as exlusion in windows defender. these is the solution.
Running the TS (Thread Safe) version of php can slow things down a lot. TS is generally never needed, so use a NTS (Non-Thread Safe) version of php.
[Edit addition, stolen from Quora]
Thread Safe (TS) and Non-Thread Safe (TS) are the two different PHP builds available.
Thread-safety ensures that when the shared data structure is manipulated by different threads, it is free from race conditions. This version is recommended where the web server run multiple threads of execution simultaneously for different requests.
For example, in Apache server, if we use mod_php as worker MPM, thread-safe version should be used.
Non-thread-safe version on the other hand is used where PHP is installed as a CGI binary. Here every request is handled separately which removes the need of thread-safe version. Moreover, using thread-safe version here degrade the performance due to unnecessary checks for thread safety. Servers like IIS & NGINX do not need thread safe versions.
I figured out that Eclipse did not end a XDebug session properly. I solved the problem by restarting the debug session and ending it properly.
for me has been an improvement after changing all of above to change from https://localhost to https://127.0.0.1
For chrome users: I found out (after trying all hints above) that the Chrome extension "Evernote Web Clipper" is also slowing down chrome.
When loading a plain URL without any includes:
enabled / disabled Evernote Web Clipper: 0,7ms / 0,25ms
For me, mcAfee Web boost extension was the Blocker. I removed the extension and now it speeds up by 90%
If you are using mysql db within your PHP script, pls check your db connection config.
Use 127.0.0.1 instead of localhost in case of db host on windows (10).
Solved php - WAMP/XAMPP is responding very slow over localhost / wordpress
The easiest way is that go to c dirive > xamp > php folder > search php.ini > clink on top then find max_execution_time anset it to max_execution_time=300 > now restart xamp > all done :)
max_execution_time=300
I'm using a Mac and I've installed the Mongo Driver for PHP (5.3.1, my version). It shows up on php info but when I use it in my PHP script it wont work.
Here is what my PHP info shows:
MongoDB Support enabled
Version 1.0.11
Directive Local Value Master Value
mongo.allow_empty_keys 0 0
mongo.allow_persistent 1 1
mongo.auto_reconnect 1 1
mongo.chunk_size 262144 262144
mongo.cmd $ $
mongo.default_host localhost localhost
mongo.default_port 27017 27017
mongo.long_as_object 0 0
mongo.native_long 0 0
mongo.utf8 1 1
Thanks :)
I'm assuming that the version of mongo listed in phpinfo is 1.2 -- MongoClient class wasn't out until v1.3
if so, you need to update mongodb to the newer version.
https://bugs.launchpad.net/ubuntu/+source/php-mongo/+bug/1096587