My php version was 7.1.33 but in order to install a specific Laravel project I needed at least version 7.2. I’m using a Mac with High Sierra (10.13) installed.
So I installed homebrew and then this:
brew install [email protected]
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
brew link [email protected]
According to php -v
(in the directory of the laravel project) my version is 7.2.33, MAMP is using 7.2.8, so this is fine I think.
which php
shows me: /usr/local/bin/php
and php --ini
gives me /usr/local/etc/php/7.2
where my php.ini is and /usr/local/etc/php/7.2/php.ini
where the loaded configuration file is located.
In the browser phpinfo of Mamp gives me these paths instead:
php.ini: /Applications/MAMP/bin/php/php7.2.8/conf
loaded configuration file: /Applications/MAMP/bin/php/php7.2.8/conf/php.ini
When trying to ‘composer install’ in said project I get an error that I can’t install some extensions. This extensions are listed in Mamp’s php.ini but not in the /usr/local/etc/php/7.2/php.ini the terminal gave me.
I’m confused what to do to resolve this issue, did I failed to install php 7.2 correctly?
Has anyone an idea what exactly went wrong or how I can use the correct php.ini (the Mamp’s one, where the extensions are listed) in the terminal when installing the composer of the project?
3
Answers
I just manually installed the extensions I needed, updating php worked fine.
If you just want to ignore the composer error; add the platform config to your composer.json.
For example:
The fact is, MAMP will use its own PHP version and configuration files and will ignore the brew-installed ones. Your terminal, on the other hand, will do the opposite.
So you need to tell your system to use MAMP php by adding its bin folder to the path:
Note: you should remove
/usr/local/opt/[email protected]/bin
from your path, check your~/.bash_profile
fileIf you want to keep system php and MAMP php separated, you could alias a different command for the mamp PHP:
and then invoke composer using it: