MAMP Error – Unable to load dynamic library redis.so

I’m at the end of my patients, God knows what was update, MAMP or Brew or something else but I ended with this nasty error for Redis integration:

Warning: PHP Startup: Unable to load dynamic library 
'/Applications/MAMP/bin/php/php5.6.32/lib/php/extensions/no-debug-non-zts-20131226/redis.so' - dlopen(/Applications/MAMP/bin/php/php5.6.32/lib/php/extensions/no-debug-non-zts-20131226/redis.so, 9): image not found in Unknown on line 0

Whaaat was that?

Ok, I know I don’t have the redis library or php is not able to load dynamically the library therefore  I fixed this couple times through different methods, like:

  • install the library through brew
  • install phpredis through macport

But, I have MAMP I don’t want to mess with brew if it’s not necessary, I want to keep it simple and mostly I need a damn quick solution.

I need redis in my project otherwise I would disable the extension from php.ini .

Solution:

Anyway, decided to take the straight approach. The error says it doesn’t have the redis.so in that location. A short search on google revealed a github project with Pecl redis Extension for MAMP 3.x & 4.x I forked the project so it would be available at any point at this location: https://github.com/obsergiu/php-redis-mamp.  And:

  1. From the upper error got the version of php: php5.6.32
  2. Checked if the path from the upper error exists:
    1. Open Finder
    2. Pressed the combination of keys CMD+SHIFT+G or from top menu Go > Go to Folder and past the path from the error:  /Applications/MAMP/bin/php/php5.6.32/lib/php/extensions/no-debug-non-zts-20131226/ if it opens we’re good to go and skip (c).
    3. In terminal just run the following command which will create the entire folder structure (the folder might look different for a different version of PHP):
      mkdir -p /Applications/MAMP/bin/php/php5.6.32/lib/php/extensions/no-debug-non-zts-20131226/
  3. Download from github the redis version closer to what php version you have and save to(created directory): /Applications/MAMP/bin/php/php5.6.32/lib/php/extensions/no-debug-non-zts-20131226/

That’s it, that’s everything. I saved the file in the location it was looked by MAMP and everything works properly.

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.

Read more “PHP extension mcrypt, intl, … missing as composer uses default environment”