OSX El Capitan, MAMP 3.5, and CakePHP 3

It’s been a while since I’ve done any development on the Mac. So, I had a fresh install of OSX 10.11.2 El Capitan to see what’s changed in 5 years. The first thing I did was download MAMP (https://www.mamp.info/en/downloads/) because that’s what I’m used to and it’s so fast to get up and running. Just download, install and you’re ready to go. I was surprised to see that MAMP now supports Nginx and also PHP 7. I decided to just stick with PHP 5.6.

Install Cakephp 3

Next, I head over to the CakePHP website and try to install it (http://book.cakephp.org/3.0/en/installation.html). It looks like you need to install composer first with this command:

$ curl -s https://getcomposer.org/installer | php

Cool, it works. Then I run the command to create a new CakePHP application.

$ php composer.phar create-project --prefer-dist cakephp/app my_app_name

It sort of worked, but complained about a missing international extension or something. When I tried to load up the page, I had a 500 error. After a few minutes of digging in the php settings to try and find the extension, I tried googling for some answers. Oddly, I didn’t find anything helpful in English, but found this Japanese site that had some answers http://qiita.com/YoshikiNakamura/items/bcceaaa3d064a08233c1. Luckily, I can read some Japanese from living there for 5 years.

From there I could see where I went wrong. I think the main problem is that composer was using the system pre-installed version of PHP which didn’t have the international extension. The MAMP PHP version did have the extension, so all I had to do was edit the PATH variable to make sure it used the MAMP PHP instead of the system PHP. I just edited my .bash_profile in my home directory and added this one line:

export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH

Make sure to use the correct path to the version installed with MAMP as mine was different from the one in the Japanese article. Once that’s done run:

$ source ~/.bash_profile

and then:

$ which php

It should now be using the MAMP version of PHP. Running the composer command to install the CakePHP application should work now and you are on your way!