How to run composer on MAMP 's php version?
Asked Answered
V

2

6

I can't run composer install because my php's version on my OS is not enough updated (5.5.36). So i tried to install composer globally with my MAMP's php(5.6.10)

1) I create alias for my MAMP's php

nano ~/.bash_profile
alias phpmamp='/Applications/MAMP/bin/php/php5.6.10/bin/php'

2) Run this line to install composer

curl -sS https://getcomposer.org/installer | phpmamp

3) Run this line to move composer

sudo mv composer.phar /usr/local/bin/composer

Composer is installed (run composer on terminal works)

This is a the tutorial.

But when i want to run composer install, composer uses my OS php.

Any idea ?

Violette answered 29/11, 2016 at 17:6 Comment(2)
From a terminal, does $ which php output the same location as your phpmamp alias?Zootechnics
No it doesn't, output /usr/bin/php.Violette
V
3

Those lines worked for me. I override the OS PHP path to my MAMP PHP path.

PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
$ export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
$ source ~/.bash_profile

You can check the version by running :

$ which php

The complete solution

Thanks to @Andrew Patton

Violette answered 30/11, 2016 at 9:43 Comment(0)
D
0

This is an old question, but it came up in web search for a similar issue I was having, and the latest version of MAMP Pro (mine is 6.6.2) has a GUI solution:

enter image description here

In Languages > PHP, under 'Default version', you should see a checkbox for "Also activate shortcut for Composer".

What this did for me is add an alias of composer=/Applications/MAMP/bin/php/composer (in my zshell ~/.profile file on macOS Monterey). Maybe yours works similarly.

Of course, when switching PHP versions, it wouldn't also switch composer versions (which is necessary when switching between PHP 5 and 7.2.5+), so I have to use the OS install for one version and MAMP's for another. A little tricky, but if you don't have this problem, then the alias will be fine.

Durmast answered 27/9, 2022 at 18:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.