I recently installed xdebug on my ststem and wanted to increase xdebug.var_display_max_depth from 3 to 10. How can I go about doing that?
There are two ways to do that. You can edit this value locally and globally too.
Local setting ("Local value") in your own PHP file:
<?php
ini_set('xdebug.var_display_max_depth', '10');
// here comes your code...
?>
Global setting ("Master value") in php.ini:
First locate your php.ini file.
In phpinfo(), you can get to know where it is from "Loaded Configuration File" directive.
You can also locate it using command prompt/terminal:
Windows: php --ini | findstr /C:"Loaded Configuration File"
Linux/UNIX-like: php --ini | grep 'Loaded Configuration File'
using php_ini_loaded_file(): <?php echo php_ini_loaded_file(); ?>
Open your php.ini in a text editor file.
You have to put something like the following to this file (in this example, I'm using php_xdebug-2.2.3-5.3-vc9-nts.dll (use http://xdebug.org/wizard.php to get to know which version you need)), and of course, you need to substitute <path to your XDebug> to the appropriate path:
[Xdebug]
;; <path to your XDebug> is like
;; C:\Program Files (x86)\PHP\v5.3\ext in Windows
;; (should be e.g. in PHP directory's "ext" subdir)
;; [backslash UNDER WINDOWS, / under UNIX-like operating systems]
zend_extension = "<path to your XDebug>\php_xdebug-2.2.3-5.3-vc9-nts.dll"
;; HERE comes the answer to your question, we set the mentioned variable to 10
xdebug.var_display_max_depth = 10
Simple as that... you can check the results in phpinfo's xdebug part in a table: there will be a "Local value" and a "Master value" column.
Here's a sample screenshot from my localhost server; in this example, the global configuration is 3, but I set the local value to 10, with the above mentioned ini_set():
In addition to Sk8erPeter answer you can of course set it in your .htaccess file for faster management:
php_value xdebug.var_display_max_depth 10
Related
I'm trying to install Symfony on XAMPP and I keep getting numerous errors.
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
In case you used any of those methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set
date.timezone to select your timezone. in
/Applications/XAMPP/xamppfiles/htdocs/vendor/monolog/monolog/src/Monolog/Logger.php line 233
and then
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-
install-cmd event terminated with an exception
and finally
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
I've tried changing the date.timezone in my php.ini file and using the date_default_timezone_set() function in the command line before trying to install it and nothing seems to work.
I've been staring at it for a while so any help is appreciated
If you can't set it correctly in your php.ini for some reason then you can set it as the first thing in your AppKernel, like so..
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
date_default_timezone_set('Europe/London');
parent::__construct($environment, $debug);
}
public function registerBundles()
{
$bundles = array(
....
);
}
....
}
Found a similar way to fix this issue while other didn't.
First check where the CLI php.ini is located:
php -i | grep "php.ini"
In my case I ended up with : Configuration File (php.ini) Path => /etc
Then cd .. all the way back and cd into /etc, do ls in my case php.ini didn't show up, only a php.ini.default
Now, copy the php.ini.default file named as php.ini:
sudo cp php.ini.default php.ini
In order to edit, change the permissions of the file:
sudo chmod ug+w php.ini
sudo chgrp staff php.ini
Open directory and edit the php.ini file:
open .
Tip: If you are not able to edit the php.ini due to some permissions issue then copy 'php.ini.default' and paste it on your desktop and rename it to 'php.ini' then open it and edit it following step 7. Then move (copy+paste) it in /etc folder. Issue will be resolved.
Search for [Date] and make sure the following line is in the correct format:
date.timezone = "Europe/Amsterdam"
It is very very common for WAMP/XAMPP and other stacks to have use of multiple php.ini files - one for cli and one for web.
Since you're expiriencing the error from CLI try the following:
php -i | grep "php.ini"
this will output location of php.ini used for cli. Edit the date.timezone there.
As for the web mode, create a file foo.php within your "web" directory of symfony containing only"
<?php phpinfo(); ?>
And, again, find the location of php.ini used and edit the date.timezone.
Edit your php.ini (not necessarily at /etc/php.ini - use php -i | grep ini to find your version) and add your timezone.
E.g. for America / New York it would be:
date.timezone = "America/New_York"
See http://php.net/manual/en/timezones.america.php
It's been mentioned but this is as simple as:
sudo cp /etc/php.ini.default /etc/php.ini
You can't set the timezone if it can't find the php.ini 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.
why do I get the following PHP warning each time I open the Terminal.app on OS X?
Last login: Mon Dec 22 11:53:25 on ttys000
PHP Warning: Unknown: It
is not safe to rely on the system's timezone settings. You are
required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those
methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected the timezone 'UTC' for
now, but please set date.timezone to select your timezone. in Unknown
on line 0
machine:~ user$
I have noticed this only today, previously I didn't have this Warning displayed.
I have PHP date.timezone set inside the php.ini:
[Date]
; Defines the default timezone used by the date functions
; Will be changed by MAMP to system timezone
date.timezone = "Europe/Moscow"
This directive is inside the php.ini located at /Applications/MAMP/bin/php/php5.6.2/conf/php.ini, which is the one PHP configuration file my PHP uses from the CLI also:
machine:~ user$ which php
/Applications/MAMP/bin/php/php5.6.2/bin/php
machine:~ user$ php -i | grep "Configuration File"
Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.6.2/conf
Loaded Configuration File => /Applications/MAMP/bin/php/php5.6.2/conf/php.ini
I have also checked the php.ini of the pre-installed PHP inside /private/etc/php.ini (aliased by /etc/php.ini), and I have set the date.timezone directive there also.
So why do I still get this nasty warning?
Thank you for the attention!
EDIT: this is the output of php --ini:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.6.2/conf
Loaded Configuration File: /Applications/MAMP/bin/php/php5.6.2/conf/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
It seems that the only loaded conf file is the php.ini of MAMP, but why do I keep obtaining that warning when I start the terminal?
I have found the problem. It was this line inside the .bash_profile in my home folder:
export PHP_API_VER=`php -i | grep 'PHP Extension =' | grep -oE '[0-9]+'`
I use this variable to know which PHP API extension I am currently using. As this variable export was after this one:
PATH="$MAMP_PHP_BIN_FOLDER:$PATH"
Which adds the PHP bin folder (where the php command is located) to the PATH env var, I experienced that error because when opening Terminal.app the wrong php command was used I had to put PHP_API_VER export after the PATH one.
Then I asked myself "Why do I obtain that warning if I have both MAMP PHP and OS X pre-installed PHP .ini files with the date.timezone directive set?", and the answer was a which php when .bash_profile did load, which revealed:
/usr/local/bin/php
What?! I had another version of PHP installed I forgot about (I installed it with HomeBrew). So I checked the php.ini of that php command, added the date.timezone directive and everything is great and works now.
Bye!
I'm trying to install Symfony on XAMPP and I keep getting numerous errors.
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
In case you used any of those methods and you are still getting this warning, you most likely
misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set
date.timezone to select your timezone. in
/Applications/XAMPP/xamppfiles/htdocs/vendor/monolog/monolog/src/Monolog/Logger.php line 233
and then
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-
install-cmd event terminated with an exception
and finally
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
I've tried changing the date.timezone in my php.ini file and using the date_default_timezone_set() function in the command line before trying to install it and nothing seems to work.
I've been staring at it for a while so any help is appreciated
If you can't set it correctly in your php.ini for some reason then you can set it as the first thing in your AppKernel, like so..
class AppKernel extends Kernel
{
public function __construct($environment, $debug)
{
date_default_timezone_set('Europe/London');
parent::__construct($environment, $debug);
}
public function registerBundles()
{
$bundles = array(
....
);
}
....
}
Found a similar way to fix this issue while other didn't.
First check where the CLI php.ini is located:
php -i | grep "php.ini"
In my case I ended up with : Configuration File (php.ini) Path => /etc
Then cd .. all the way back and cd into /etc, do ls in my case php.ini didn't show up, only a php.ini.default
Now, copy the php.ini.default file named as php.ini:
sudo cp php.ini.default php.ini
In order to edit, change the permissions of the file:
sudo chmod ug+w php.ini
sudo chgrp staff php.ini
Open directory and edit the php.ini file:
open .
Tip: If you are not able to edit the php.ini due to some permissions issue then copy 'php.ini.default' and paste it on your desktop and rename it to 'php.ini' then open it and edit it following step 7. Then move (copy+paste) it in /etc folder. Issue will be resolved.
Search for [Date] and make sure the following line is in the correct format:
date.timezone = "Europe/Amsterdam"
It is very very common for WAMP/XAMPP and other stacks to have use of multiple php.ini files - one for cli and one for web.
Since you're expiriencing the error from CLI try the following:
php -i | grep "php.ini"
this will output location of php.ini used for cli. Edit the date.timezone there.
As for the web mode, create a file foo.php within your "web" directory of symfony containing only"
<?php phpinfo(); ?>
And, again, find the location of php.ini used and edit the date.timezone.
Edit your php.ini (not necessarily at /etc/php.ini - use php -i | grep ini to find your version) and add your timezone.
E.g. for America / New York it would be:
date.timezone = "America/New_York"
See http://php.net/manual/en/timezones.america.php
It's been mentioned but this is as simple as:
sudo cp /etc/php.ini.default /etc/php.ini
You can't set the timezone if it can't find the php.ini file!!!!
On windows8 I got this with php 5.3:
echo sys_get_temp_dir();
output:
C:\Windows
Am I not understand something or it is a bug?
UPD
trying $_ENV:
<?php
var_export($_ENV);
output:
array ( )
Checking upload_tmp_dir:
<?php
echo ini_get('upload_tmp_dir');
output:
C:\Windows\Temp
Looking at the PHP source, it will call GetTempPath to determine the temp directory. According to the documentation, the windows directory C:\Windows is the last fallthrough option. You should check under which user profile PHP or its host process is running, maybe the environment needs some fixing.
Related to this PHP Bug (only CGI context?).
I have the same problem and the solution is to change the apache configuration to expose the TEMP system environment variable to PHP with this directive in apache configuration file (httpd.conf) :
PassEnv TEMP
Don't forget to activate the env_module, generally uncomment the line "LoadModule env_module modules/mod_env.so".
This solution fixes the result of these PHP functions: sys_get_temp_dir(), tempnam().