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
Change the default Mac OS X PHP to MAMP's PHP installation and install Composer package management
Instructions for changing PHP installation
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:
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):
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.Please follow these simple steps:
In the terminal, run
vim ~/.bash_profile
Type
i
and paste the following at the top of the file:Press
ESC
, enter:wq
, then pressEnter
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).
Install Composer Package Management
Now you can trigger the command to install composer globally (so you can access it from anywhere):
You can verify that the installation works by typing the following command in the terminal:
It will show you the current version and a list of commands you can use after successful installation.
Original source