Often times I use PHP from the command line on my MAC for development purposes. And if you’re like me, you’re not going to always remember your settings or remember if you updated something and it changed the php.ini location. You have more important things to worry about.
You probably have MAMP running, right? Can’t you just check the MAMP settings? Well, here’s the thing. You might not have MAMP php from the command line; instead you’re using a version of PHP that came with your MAC, or a version of PHP that came from homebrew or mac ports.
Point being, it’s an easy thing to forget, but here’s an easy solution to find the php.ini location:
php --ini | grep Loaded | cut -d" " -f12
That will spit out the path to your php.ini file that your command line PHP is loading in.
This might not be easy to remember, and you might not always be able to Google this page. That’s why you’re probably going to want to save this in a script somewhere. You choose the location. For simplicity, just do something like this:
echo 'php --ini | grep Loaded | cut -d" " -f12' > ~/get_phpcli_ini.sh; chmod 700 ~/get_phpcli_ini.sh
That way, even if you don’t have your PATH configured properly, you can do something like this:
And it will spit out the path to your php.ini file that MAC’s php command line uses. You can get more advanced if you want, I won’t punish you for that =) But don’t complicate things too much. Always try and keep it simple, there are more important things to worry about.