I tried to install the Google client library using Composer, but I can't install Composer or use php on the command line.
I'm using php 8.0.8 with MAMP and it works fine so I know it's installed. If I type php in the terminal I get a command not found message. Thinking it might be an environment variable, I tried navigating to the php folder /Applications/MAMP/bin/php/php8.0.8/lib/php and tried the php command again, but still got the same error
I'm using a Mac running Monterey
P粉0072885932023-11-10 00:26:47
First, let's find out what version of PHP we're running (to know if it's the default version).
To do this, trigger this command within the terminal:
which php
This should output the Mac OS X pre-installed default PHP installation path, which by default must be (assuming you haven't changed it before):
/usr/bin/php
Now we just need to swap it to the PHP installed with MAMP, which is located at /Applications/MAMP/bin/php/php5.4.10/bin
(MAMP 2.1.1) 3)
To do this, we need to edit .bash_profile
and add the MAMP version of PHP to the PATH variable.
In the terminal, run vim ~/.bash_profile
Type i
and paste the following at the top of the file:
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
Press ESC
, enter :wq
, then press Enter
In the terminal, run source ~/.bash_profile
In the terminal, type which php
again and look for the updated string. If everything was successful, it should output the new path to the MAMP PHP installation.
If it doesn't output the correct path, try closing the terminal window (quit completely) and opening it again and it should apply the changes (restart for short).
Now you can trigger the command to install composer globally (so you can access it from anywhere):
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
You can verify that the installation works by typing the following command in the terminal:
composer
It will show you the current version and a list of commands you can use after successful installation.