Monday, April 20, 2015

Symfony2 install intl extension on Mac Mamp solution

Notes:

Why MAMP ? Because it’s the easiest way to work locally with Symfony 2 at the moment. It comes with an updated APC extension and requires only the INTL extension which we will compile in this how-to. Please follow the requirements and instructions step by step.

Requirements:

  1. Download and install Xcode from the App Store. (current release 4.3.3).
  2. Download and install the Command Line Tools for Xcode from Preferences > Downloads in Xcode.
  3. Install Macports. Follow the instructions on Macports

Step 1: Get the Web-Server

Go to Mamp and download the current version of MAMP. After installing delete the MAMP PRO directory (you won't need it) and run MAMP.
In the window click on Preferences… then on Ports. There change the current server ports to their default ports. MAMP will automatically restart both servers so we can finally start setting up Symfony 2.

Step 2: Get the framework

Go to Symfony and download the current release (2.1.3). Unpack it and move the Symfony folder to your local htdocs which is located in: /Applications/MAMP/htdocs
Now we will configurate our web-server to make Symfony 2 work. Open the following URI in your Browser:http://localhost/Symfony/web/config.php
You will most likely get something like this:
Symfony Recommendations

Step 3: Get the extensions

  1. Open your Terminal by either pressing both [⌘ + space] and writing Terminal or from the filesystem/Applications/Utilities/Terminal.app and type:
    1. sudo port install php5-intl
    or if you have PHP 5.4.X (thanks to Andrew Knight):
    1. sudo port install php54-intl
    In case you get the warning that no indexes could be found run the following line and then try the upper command again:
    1. sudo port -d sync
  2. Get yourself some tea and try to gather some reputation on Stackoverflow. This is going to take some time.
  3. Type the following into your Terminal and press [tab] for auto-completion - then [return]:
    1. cd /opt/local/lib/php/extensions/no-debug-non-zts-
    (the php extentsions folder maybe in different location my one is /opt/local/lib/php54/extensions/no-debug-non-zts-20100525/intl.so) Now your are located in the directory where our extension has been compiled (via Terminal). Type:
    1. open .
    Now your Finder is going to popup just where our intl.so extension is located. Copy that file and put it into your MAMP php-extensions directory. For PHP 5.3 it would be:
    /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-yyyymmdd/

Step 4: Do the configuration

  1. Navigate to the following directory (via Finder and assuming with PHP 5.3) to change a few settings:/Applications/MAMP/conf/php5.3/
  2. Now drag the file php.ini onto your desktop (where you can edit it) an open it with your favorite text editor. I did the changes with the default editor TextEdit.
    [⌘ + F] and search for short_open_tag and change it to off.
    [⌘ + F] and search for magic_quotes_ and add the following line after: magic_quotes_sybase = off
    magic_quotes_gpc = off
    [⌘ + F] and search for 'extension=apc.so' and add the following line to the extensions section:
    extension=intl.so
  3. Now save and move the file back to it’s original directory. Now restart your web-server (via Mamp).