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

Solution 1:

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

Solution 2:

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 => /etc
Loaded Configuration File => /etc/php.ini

On Windows, use find instead:

php -i | find/i"configuration file"