How can I find the php.ini file used by the command line? How can I find the php.ini file used by the command line? php php

How can I find the php.ini file used by the command line?


Just run php --ini and look for Loaded Configuration File in the output for the location of php.ini used by your CLI.


You can get a full phpinfo() using:

php -i

And, in there, there is the php.ini file used:

$ php -i | grep 'Configuration File'Configuration File (php.ini) Path => /etcLoaded Configuration File => /etc/php.ini

On Windows, use find instead:

php -i | find/i"configuration file"


You can use get_cfg_var('cfg_file_path') for that:

To check whether the system is using a configuration file, try retrieving the value of the cfg_file_path configuration setting. If this is available, a configuration file is being used.
Unlike phpinfo() it will tell if it didn't find/use a php.ini at all.
var_dump( get_cfg_var('cfg_file_path') );

And you can simply set the location of the php.ini. You're using the command line version, so using the -c parameter you can specify the location for this particular run, e.g.

php -c /home/me/php.ini -f /home/me/test.php