webgrind on wamp - 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!

Related

In PHPstorm after configuration xdebug, stepover is disabled yet.what should I do? and one addition warning

Please guide me
No one here knows how to solve the problem!?
I use PHPstorm 2017.2.4 for php programming.
I configured phpstorm to debug by xdebug for use stepover and stepintro in debugging by jetbrain guid documents but just debugging is enable yet and other options is disable. screen shot of this:
How can I and What should I check to resolve this problem?
I googled and search in stackoverflow but I couldn't find my answer.
Update:
I couldn't solve that yet.
I explain all steps I have done :
first o all say that I use wamp 2.4 for local host server.(php 5.4.12, apache 2.4.4 , MySQL 5.6.12)
1- install phpstorm for use debugger such as step over an step into debugging.
2- use jetbrain guide documents to install debugger:
first check to find xdebug in wamp directory.
then edit last lines of php.ini file in wamp as following:
[xdebug]
zend_extension = "c:/wamp/bin/php/php5.4.12/zend_ext/php_xdebug-2.2.3-5.4-vc9-x86_64.dll"
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"
3-Set php interpreter as follow image:
4-Then validate debugger here that don't disply any warning:
5-Enable listening for PHP debugger connection
6- Install chrome toolbar JetBrains IDE Support for web debugging.
7- I wentback to PHPstorm to debugging but just debug option was enabled and others was disabled as first image in this post.
In addition, after debugging the codes, the warning : "PHP Warning: include_once(): Failed opening '.\dref.php' for inclusiondisplay this warning. (include_path='.;C:\php\pear') in C:\wamp\www\srn\mrt\req_v.php on line 260" is displayed, while the same code works well in the WAMP(localhost:80) by Firefox browser.
in all php documents that has code similar to below :
include_once ('.\jd.php');
require_once(".\dref.php");
require_once(".\scur.php");
Then when I changed path for example ".\dref.php" in require_once to "..\dref.php" debugging dont display above warning ,But this timewhen open web by Firefox(localhost:80-wamp) display Warning: require_once(..\dref.php): failed to open stream: No such file or directory in C:\wamp\www\srn\mrt\req_v.php on line 26
Where do I make mistakes and how should I solve these problems?
Please guide me
No one here knows how to solve the problem!?

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.

Windows, XAMPP, PHP 7 and opcache

I've installed latest XAMPP server with PHP 7 (update: checked also PHP 7.1) (on my Windows 10 system). Wanted to use opcache, so I enabled it in php.ini.
[opcache]
zend_extension=php_opcache.dll
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
With that change now, and with almost every page refresh, I'm getting this error from Apache:
AH00428: Parent: child process 3748 exited with status 3221226356 -- Restarting.
So, page is loading, and loading... waiting to Apache start again. When I'm turning opcache off (by setting opcache.enable=0), Apache is not restarting and everything works fine (omitting the slower web application topic, of course).
Everything works fine while loading app on XAMPP having PHP 5.6 with enabled opcache.
EDIT (added GIF image):
As you can see, sometimes page refreshes like it should. But sometimes it's refreshing much longer, and Apache is restarting in that moment.
EDIT:
To be honest, I gave up with this application and working with PHP on Windows (was working on it for around 10 years with PHP <= 5.6). It's very hard/impossible (for now) to make PHP 7.x work on that OS (with Opcache). Decided to go with Ubuntu and server created with Docker. Everything is easier to configure (especially with Docker) and works faster. I advise everyone to do the same ;).
Your php_opcache.dll path seems wrong, you need write it like below, it works for me.
[opcache]
zend_extension=C:\xampp\php\ext\php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.max_accelerated_files=2000
More details
If your XAMPP comes with PHP 5.5+ by default, opcache already included in the bundle, you will just need to enable it. To enable the extension:
Open php.ini (by default it should be located here: C:\xampp\php\php.ini).
Add this line at the end of the file:
zend_extension=C:\xampp\php\ext\php_opcache.dll
Restart Apache server.
open a php.ini file
Change the ;opcache.enable=1 to opcache.enable=1
Add opcache dll path at the end of the file zend_extension = "C:\xampp\php\ext\php_opcache.dll"
Restart apache
for more reference check this video https://www.youtube.com/watch?v=GvWrNoRDjUY
In case of Xampp, just put the below lines next to [opcache]
zend_extension="C:\xampp\php\ext\php_opcache.dll"
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
To be honest - do not use xammp. Right now we have a bit better tech stack, to run PHP on Linux servers.
Docker
https://docs.docker.com/docker-for-windows/
Vagrant:
https://www.vagrantup.com/
Both of them are based on linux systems, where most of xammp problems will not have place.
First at all:
This is 2022 and I had a similar problem too with PHP-7.2, not on Xamp, but similar server.
How I've got my problem solved?
If you're here because of that, at first try to go with a default "opcache configuration options". And just above opcache.enable=1 put zend_extension=opcache. Your PHP is smart enough to find the extension. And yeah, there's no need to define the full path if you have defined it here extension_dir = [YOUR PATH] (in php.ini). Of course you can use the full path too, if you want too. The path, probably, it's not a problem if your extension is there (in the folder with all PHP extensions). Did you checked, is it there, your extension?
My problem was in this two options:
opcache.memory_consumption
opcache.interned_strings_buffer
I have no idea why, but I guess this two option should have some balance, because both of them is about memory usage.
So, this had my Apache useless, because it didn't wanted to start
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 32 ;this one BAD
next one works fine!
opcache.memory_consumption = 64
opcache.interned_strings_buffer = 16
this one is works fine too!
opcache.memory_consumption = 128
opcache.interned_strings_buffer = 32
So, as I said, at first try to go with a default values of "opcache configuration options", and later do experiments.
How to check everything works on PHP?
var_dump ( zend_version() );
var_dump ( extension_loaded("opcache") ); // bool(false) cuz it's ZEND
var_dump ( extension_loaded("Zend OPcache") ); // bool(true)
// Next one will give you a lot of data about current opcache usage,
// but of course, only if your extension is enabled.
print_r ( opcache_get_status() );
Default OPcache configuration options you can find here:
https://www.php.net/manual/en/opcache.configuration.php
Creeating directory with appropriate permissions and setting it php.ini worked!
opcache.file_cache=d:\xampp\htdocs\opcache
ThreadStackSize 8388608
Helped me in the similar case. This is a httpd option.
on php.ini add more
zend_extension=opcache
remove comment
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.max_accelerated_files=10000
restart apache

PHP on Windows with XAMPP running 100 times too slow

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

PHP: No php.ini file

I just started to learn PHP and in order to do that I installed wampserver on my windows 8.1. When I try to launch, it works properly but I have two problems:
1) I have an error in my localhost page:
*** ERROR *** The PHP configuration loaded file is: - should be: C:/wamp64/bin/apache/apache2.4.17/bin/php.ini or c:/wamp64/bin/php/php5.6.16/phpforapache.ini
I tried to find the php.ini file but it doesn't exist. In my phpinfo() it is (none) in front of Loaded Configuration file.
2) The other problem is I can't access phpmyadmin and I get this error :
"The mbstring extension is missing. Please check your PHP configuration."
Since I'm really new in php, please keep the answers simple! :)
Thanks in advance.
I just solve this problem.
to be sure to start Wampserver "As an administrator," :
right-click the shortcuts, Properties, tab Shortcut:
Select "Run as administrator"
OK
Apply
Leave Wampmanager and ursing win+x+a or others ways to open a cmd administrator command window.( attention:it should run the cmd as an administrator)
In this window, access to your apache installed path
for exemple, my path: D:\wamp64\bin\apache\apache2.4.17\bin
then type
D:\wamp64\bin\apache\apache2.4.17\bin> mklink php.ini d:\wamp\bin\php\php5.6.15\phpForApache.ini
and you will see a message likes"php.ini << === >> d:\wamp\bin\php\php5.6.15\phpForApache.ini symlink created"
close the cmd and restart Wampmanager as an administrator
I hope that my solution also works for you.
after installation of php you must rename file php-production.ini to php.ini. Those files in your root php directory installed.
For mbstring you must enable this extension. For that you must uncomment the line in your php.ini file (renamed just before) :
;extension = php_mbstring.dll
Check if you have this line in your php.ini :
[mbstring]
mbstring.language = all
mbstring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.encoding_translation = On
mbstring.detect_order = UTF-8
mbstring.substitute_character = none;
mbstring.func_overload = 0
mbstring.strict_encoding = Off
in system tray (bottom right corner of windows) left click wamp icon, php, version, and click on the current version (the one marked with green tick)
This was my issue:
* ERROR * The PHP configuration loaded file is: c:/program files (x86)/php/php.ini - should be: c:/wamp64/bin/apache/apache2.4.27/bin/php.ini or c:/wamp64/bin/php/php5.6.31/phpforapache.ini
You must perform: Right-click icon Wampmanager -> Refresh
To resolve this issue, I just went into program files(x86) and added 1 to my PHP folder to make this invisible and retarted all Wampserver services it worked fine. Could have been a conflit with my This old PHP.

Categories