I got a bit tired of this error, it’s a bit of nightmare to setup Magento2 on OSX using the MAMP PRO PHP in CLI.

As composer is not able to pick the MAMP php but instead is loading the native one (if u’re in a hurry go to end of article, to update 2, for the solution).

The entire error looks like this:

I have checked the damn php.ini file and everything  is in place.

Also bear in mind that I have added all the extensions in MAMP PHP INI file.

It seems the whole problem is because composer has this line:

For the moment I know just a few  solutions for this headache (anyone knows more please submit a comment and I’ll make sure to credit you) 

(update:  scroll at the bottom for perfect solution)

  1. Install Mcrypt through Homebrew (worked for me):

    I’m not happy with this solution as in my opinion it defies the purpose of having MAMP PRO into the system. Why I need two PHP (the brew version and mamp) to run in the same system?
  2. Execute Composer with PHP full path (it worked for Magento 1 through magerun but not for Magento2):

The  PHP extension mcrypt is often not distributed with stock PHP packages. The mcrypt extension is the standard PHP extension for encryption and hashing functionality.

This is not a proper solution – I want something which will enforce to use the proper PHP and there will be no misunderstandings.


Guess what?! Another machine (MacBook Pro) – the solution is not working. I’m about to loose my temper when I decide to check where is located composer file. It seems it was installed with Brew which meant that all the dependencies where related to Brew so I uninstalled the “dragon” and installed through the default way then I just run the full command (decided it’s faster than to install through brew the extension):



Seems MAMP is creating an alias in ~/.profile which looks like:

Now, composer is ignoring this.

Ideally MAMP should create a symlink to /usr/bin/php, but there’s permissions issues which is not allowing it.

Another solution:

Based on  

  1. edit the ~/.bashrc or in my case it was ~/.bash_profile
  2. go to end of file and add an alias, comparing to Paul’s solution I choose to make an alias to composer (overwriting composer)
  3. and the full command for composer looks like:

And it worked without issues.

Thanks Paul.

Update 2, the perfect solution:

Finally, found the perfect solution for this problem.

Just create a symlink from MAMP php installation into …….


That’s because by default the location is still in your $PATH.  So for my installation of PHP7.2.13 the only command i need to run would look like this:

need to suggest the approach to mamp team 🙂

Voaallaa – CLOSED TOPIC!