Where can I change my xdebug settings in PHP 5.4.x - php

I remember in PHP 5.3 I could easily change xdebug settings inside php.ini file. (i.e. xdebug.max_nesting_level = 200)
I have upgraded to PHP 5.4 and since then no longer I can modify xdebug settings.
I make changes in php.ini and restart the webserver but nothing happens.
Looking inside php.ini there is no definition for xdebug settings.
but when I run:
php -m
I see xdebug already loaded.
Surprisingly when I run:
php -i | grep xdebug
I see loads of xdebug settings.
So my question is where are those settings come from if they are not in php.ini
(I need to add I have checked /etc/php5/cli/conf.d/20-xdebug.ini already and there is onlu one line in it: zend_extension=/usr/lib/php5/20100525/xdebug.so)
And how can I modify these settings.

Its the same like before. Open a phpinfo and look which ini files are loaded. In one of that files should be a xdebug part and you can modify them. If there is not block for xdebug you can add them. You can put that settings to the 20-xdebug.ini if you but if there are some other settings and the order is not correct your changes aren't working.

Related

Php 5.6 opcache not showing up in Mac Sierra

I've made the possible changes to the php.in at /etc/php.ini. I didn't had php.ini so took a copy of php.ini.default. The changes I've made are
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=64
When I print phpinfo() and see the result, I tried to find opcache and it is not showing up. I'm using Mac Sierra.
Make sure you have edited the correct php.ini (it can be seen in the phpinfo() result).
Check, if the files listed in "Additional ini files parsed" does not override your settings. (e.g.: opcache.enable=0 somewhere override your php.ini setting)
If you are using PHP-FPM, that need a restart / reload to pick up the changes.

short_open_tag setting ignored by PHPUnit

My PHPUnit tests keep failing when trying to tests any .php files in my (legacy code) application that begin with the short open tag (<? instead of <?php).
But in my php.ini file, the short_open_tag is set to On.
The application runs fine. Why is PHPUnit getting upset over the short open tag? I've looked for other php.ini files, and could only find the one at /etc/php.ini. My .htaccess file doesn't affect this setting either. What else could be causing this?
General solution
1) Check which php.ini file is loaded (command line: php --ini)
2a) Set in that php ini file: short_open_tag = on
2b) Set in .htaccess file: php_value short_open_tag 1
3) Restart the server (command line: service httpd restart)
So, I got it to work and the solution is frustrating: My application is on a VM and the php.ini file within the VM had the correct setting. However, PHPUnit was using the php.ini file on my local machine, which had short_open_tag set to Off. Changing that setting fixed my problem.
(I'm still unsure of why PHPUnit uses the other php.ini, but I think that's outside the scope of this question.)
PHPUnit uses PHP-cli module of PHP. And PHP-cli has another .ini file for its configuration. I am using ubuntu 14.04, in my case
/etc/php5/apache2/php.ini //used for web compiler
/etc/php5/cli/php.ini // Used for PHP-cli, you need to set short_open_tag=On here

Composer can't find ext-mbstring even though it is installed

When I attempt to install Laravel 5 I get a dependency error. I'm using Uniform Server on Windows 7. I have enabled php_mbstring.dll and I checked it's loading properly. (I think)
Here is the console output (Composer):
Here are the extensions in my php.ini
Here are the phpinfo() mbstring details:
I don't know where to go from here.
Any idea?
Pay attention that, both in Windows and Linux, PHP can run with multiples php.ini configuration files.
In general, when you find this kind of issue, you have to double check that the configuration file loaded is the same that you are editing or you need to find the right path and add the extension also to the right php.ini configuration file.
While running a script through a web server, you can find the configuration file using the function
phpinfo();
and checking the line "Loaded Configuration File" (or just look for php.ini)
For what concern the CLI you can run in CMD
php --ini
and check the first lines in order to find the Loaded Configuration File value.

Can't set/find detect_unicode to Off

I'm want to start using phpDocumentor and the manual installation keeps throwing an error about me not having set detect_unicode = Off in my php.ini in Terminal.
When I add it to my php.ini it doesn't take and I get the same issue when running the install. Nobody seems to have this problem, and for the life of me I can't figure it out.
https://github.com/phpDocumentor/phpDocumentor2/blob/develop/README.md#installation
What am I missing? (I did restart the MAMP server after the php.ini edit)
Screenshot of the error in terminal...
If you have MAMP/MAMP Pro installed then the problem is that the PHP version available to your terminal will most probably be the system version located in:
/private/etc/
I had the same problem but in my case I didn't have a php.ini file in that directory so the best way to resolve it is to just create a symbolic link to the PHP version currently in use in your MAMP/MAMP Pro installation:
php.ini -> /Applications/MAMP/bin/php/php5.3.14/conf/php.ini
That solves the issue. Just change the php version php5.3.14 to whatever version of PHP you've selected to use in MAMP.
As #moderndegree mentions above, you can then optionally make this available to the terminal in the future by editing your path variable in your bash/zsh/etc:
export PATH="/Applications/MAMP/bin/php/php5.3.14/bin:$PATH"
You must not be editing the right php.ini if it still is enabled. Run php -i | grep ini to find all the ini files that are loaded.
The relevant lines are those two:
Loaded Configuration File => ...
Additional .ini files parsed => ...
The problem is that you are probably hitting a different php install.
Try the following:
which php
If you get anything other than, /Applications/MAMP/bin/..., you need update your environment to point to MAMP's installation.
To do this, you will need to add the following to .bash_profile (please update the path to match your setup):
export PATH="/Applications/MAMP/bin/php/php5.3.6/bin:$PATH"
Reload .bash_profile with the following command:
source .bash_profile
After you do this, you should be pointing to the correct php installation. Try which php again to confirm. Now run php -i | grep ini to confirm that the correct php.ini file is being loaded. As Seldaek stated, the relevant lines are:
Loaded Configuration File => ...
Additional .ini files parsed => ...
As I remember, MAMP uses configuration templates. So you should edit php.ini template. The actual php.ini will be regenerated from the template everytime you restart MAMP.
I faced the same problem for composer-php and i add this line manually into php.ini file. Like this:
sudo /private/etc/php.ini
then add this line "detect_unicode = Off"
detect_unicode = Off
then its work and i installed composer. You can see this
How to disable "detect_unicode" setting from php.ini? (trying to install Composer)
If you can't change your /usr/local/bin/php/php.ini file, remember to keep using '-d detect_unicode=Off' for all your php calls like so:
curl -s https://getcomposer.org/installer | php -d detect_unicode=Off
php -d detect_unicode=Off composer.phar install
If you are able to change your php.ini file, then add the following to the end of your php.ini:
detect_unicode = Off

Eclipse and Xdebug does not parse additional ini files in /etc/php5/conf.d

I have setup Eclipse 3.6.2 on Ubuntu 11.4 for AMD64 and Xdebug.
Eclipse was installed with zip download from eclipse.org.
PHP and Xdebug were setup with apt-get.
When I run the PHP script in the shell they will use the /etc/php5/php.ini file and parse additional ini files in /etc/php5/conf.d/.
When I run in Eclipse (run mode or debug mode) it will only parse php.ini and no additional ini files.
Basically, all extensions, are not loaded.
It is an intentional bug.
PDT executes php with "-n" option always. It makes additional ini files unavailable.
see https://bugs.eclipse.org/bugs/show_bug.cgi?id=339547
also https://bugs.eclipse.org/bugs/show_bug.cgi?id=347618
BTW, you'll be able to add a shell script which trims "-n" option as PHP Executable.(Preferences>PHP>PHP Executables)
For example,
#!/bin/sh
if [ $1 = "-n" ]; then
shift;
fi
/usr/bin/php $*
The answer #atlanto gives as a work around did and does still work, but recent version of Eclipse (I'm on Neon) has a fix that may work for you if you don't mind using the php.ini and conf.d set by default for the php executable.
The failing to load additional files only happens now if you put in an explicit php.ini file when defining a PHP executable. Leave this blank and check the box Use system default php.ini configurate.
Now if you use the location/php.ini that was specified as default when the executable was built, it will respect scanning of conf.d directories.
Here's how to check if your php has scanning conf.d enable and where the approriate default location is:
php -i "(command-line 'phpinfo()')" | grep "Configure Command"
You should see something like:
Configure Command => './configure' '--prefix=/usr/local/Cellar/php5/5.6.29_5'
'--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/5.6'
'--with-config-file-path=/usr/local/etc/php/5.6'
'--with-config-file-scan-dir=/usr/local/etc/php/5.6/conf.d'
'--mandir=/usr/local/Cellar/php56/5.6.29_5/share/man'
... and so on...
The items that matter are:
with-config-file-path: this where it will look for your php.ini file
with-config-file-scan-dir: this is the conf.d that will be scanned
If you still wish to choose a different in location than the default for the executable your options are:
Inline the module directives from and file in conf.d into your alternate php.ini
Rebuild php and set the above options to your new location as default
Use the wrapper script #atlanto indicates

Categories