PHP extension mcrypt, intl, … missing as composer uses default environment

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:

Problem 1
- Installation request for magento/framework 100.1.5 -> satisfiable by magento/framework[100.1.5].
- magento/framework 100.1.5 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.

Problem 2
- Installation request for magento/magento2-base 2.1.5 -> satisfiable by magento/magento2-base[2.1.5].
- magento/magento2-base 2.1.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.

Problem 3
- Installation request for magento/product-community-edition 2.1.5 -> satisfiable by magento/product-community-edition[2.1.5].
- magento/product-community-edition 2.1.5 requires ext-intl * -> the requested PHP exte
nsion intl is missing from your system.

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:

#!/usr/bin/env php

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):

    #for version PHP7.0 install:  
    brew install php7.0-mcrypt
    #while for version PHP5.6 install:
    brew install php56-mcrypt

    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):
/usr/bin/php /usr/local/bin/composer --repository-url= magento/project-community-edition ./

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):

php /usr/local/bin/composer install



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

alias php='/Applications/MAMP/bin/php/php7.2.10/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/php7.2.10.ini"'

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)
    alias composer="/Applications/MAMP/bin/php/php7.2.10/bin/php /usr/local/bin/composer"
  3. and the full command for composer looks like:
    $ composer install

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:

ln -s /Applications/MAMP/bin/php/php7.2.13/bin/php /usr/local/bin/php

need to suggest the approach to mamp team 🙂

Voaallaa – CLOSED TOPIC!