Professional Website Design Company UK
Support us Advertise Write for PM Design Submit Freebie Submit Your Website

Installing Symfony on Mac OSX with MAMP, PEAR and PDO

20
 
Posted on 15th Jul, 2010. Posted in: ,

Mac OSX Symfony installationHow to install and configure Symfony on your Mac? The answer to this question is not obvious and various people suggest different approach. I recently have installed Symfony on my machine and decided to share a few tips how to achieve it. Things are not that complicated once you know what you are doing. Let’s get strait to the point!

 

We could always you symfony sandbox but in order to gain access the the shell commands we need to configure our localhost and install Symfony on our local environment.

In this short quide I am going to describe how to install MAMP Pro 1.9 on MAC OSX Snow Leopard 10.6.4 and then how to install PEAR and Symfony 1.4 Framework.

What is Symfony?

 

Symfony is one of the most popular and powerful PHP (MVC based) Frameworks available out there. The biggest advantage of this framework is great documentation, huge community and millions of plugins to help you on your way. Symfony provides a complete solution to make your development processes faster and more efficient. On top of that, quality of your code becomes very high and further application expansion is easy.

Installing MAMP

 

First of all, install MAMP package. If you have any problems with installing it follow this tutorial: How to install localhost server on your machine – Installing MAMP. Make sure to setup your ports to default and select PHP version 5.

Installing PEAR

 

To install PEAR we are going to use go-pear.php as an alternative way to install PEAR on the Mac. As a shell command on your Terminal type:

sudo su -
curl http://pear.php.net/go-pear > go-pear.php
php -q go-pear.php

Above commands installs PEAR on /Users/YOUR_USER_NAME/PEAR. Now we need to export this path and add it to the environment variable.

echo ‘export PATH=/Users/YOUR_USER_NAME/PEAR:$PATH’ >> ~/.bash_profile
echo ‘export PATH=/Users/YOUR_USER_NAME/bin:$PATH’ >> ~/.bash_profile

By confirming all on screen alerts you should install your PEAR. Now the PEAR should be installed and configured. You can check that by typing ‘pear’ as your Terminal command.

Installing Symfony

 

Now, we are going to install Symfony. Restart your localhost and terminal first. We have MAMP environment installed on the machine so symfony is going to be installed directly from the MAMP folder. After the restart type:

cd
sudo /Applications/MAMP/bin/php5.3/bin/peardev channel-discover pear.symfony-project.com
sudo /Applications/MAMP/bin/php5.3/bin/peardev install symfony/symfony

Make sure your php path folder is correct. Go to your MAMP Application folder and check if ‘peardev’ is available under this path.

Further configuration

 

We are almost done. The last thing we need to do is to link php and mysql socket to be accessible globally. Otherwise we will be not able to access ’symfony’ command and we will be not able to connect to the database from the shell commands and we will be getting PDO error.

PDO error

We can set all up by typing:

sudo ln -s /Applications/MAMP/bin/php5.3/bin/php php
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock

To gain access to mysql commands from the shell:

alias mysql=´/Applications/MAMP/Library/bin/mysql´
alias mysqladmin=´sudo /Applications/MAMP/Library/bin/mysqladmin´
alias mysqlstop=´sudo /Applications/MAMP/Library/bin/mysqladmin -u root -p shutdown´
alias mysqlstart=´sudo /Applications/MAMP/Library/bin/mysqld_safe´

Again, make sure the MAMP paths match with yours.

Once all is done, you should be able to have access to ‘pear’ and ’symfony’ from your Terminal.

Enjoy using this great PHP framework.

Enjoyed this entry? Share it around!

 

Share it with others. Make others aware about web design tips, techniques and news.

 
 

You may also like to read

 
 
 
  • Fer

    First, congrats for the article, I found it really interesting =)
    So I decided to give it a try with my laptop (MacBook Pro 10.6.4), and repeating exactly the same steps you mentioned above. But I didn’t get it properly installed.
    Sometimes pear command is not recognized, sometimes I get “permission denied” message.. Of course I’m not an expert.. =) Anyway I can see my symfony project created, using http://test, but with no images.
    I would like to repeat the whole process if possible, but dunno how to ‘go back’ to the initial point, this is to say, install MAMP, PEAR, Symfony (inside MAMP)… etc. I’m quite new to use Mac so maybe this is more difficult that I think.
    Thanks for the post you made, really interesting guide.

  • http://www.pawelmartuszewski.co.uk Pawel

    Hi Fer,

    I had the same problem as you have now. In order to repeat everything once again I had to rollback my Mac a month back in time. If you will mess with aliases and environment variables it’s hard to set things right again.

    Try to backup everything and install your system again… I know this sounds like a lot of work, but you will be sure that everything is set correctly.

    PS. Quick fix to see the images on your project is to simply copy /sf folder (located in your symfony directory) into your /web directory of your project. Another way is to simply create an alias in your Virtual Host – pointing to this folder ( /sf ).

    Hope this helps…

  • Fer

    After reinstalling my system, I did follow this guide, but once again I didn’t get the same results as you.

    Installing MAMP, no problems, default ports, php 5.3.2 selected.

    Installing PEAR.
    ‘As a shell command on your Terminal type:’

    I did that, but it’s going to install in /private/var/root
    So I guess I have to change it to /Users/Fer and then continue with installation (Am I wrong?)
    When installing PEAR, lots of ‘errors’ or ‘warnings’ like: xxxxxx function is deprecated in xxxxx, dunno if this is normal, or will affect in the future…

    So, at the end of the installation I got this message:

    ‘Current include path: .:/usr/lib/php’
    ‘Configured directory: /Users/Fer/PEAR’
    ‘Current used php.ini (guess) : ‘

    After that, add the variables to the PATH with the export commands, once I did it, it says:
    ‘pear: command not found’

    By the way, yesterday this step worked, but when I tried
    ’sudo /Applications/MAMP/bin/php5.3/bin/peardev channel-discover pear.symfony-project.com’
    it also says ‘command not found’

    So I cannot get it working… Maybe I am missing some important step even before installing MAMP or something.

    Thanks for your time and patience ^^

  • http://www.pawelmartuszewski.co.uk Pawel

    Fer,

    Had exactly same issue with /private/var/root… The problem is when your MAC OSX installation is correct and ‘clean’, PEAR shouldn’t wish to install itself in /private/var/root . When system is clean PEAR installation shouldn’t give you any errors and ‘function deprecated’ alerts. And you shouldn’t have to change your PEAR installation directory eather.

    Are you sure you have had ‘clean’ Leopard installed? Or you just reinstalled Leopard keeping old settings? This might be the problem…

    Absolute nightmare with this Symfony installation isn’t it? My guide worked for me… Once you got the solution that works for you, please come back and share it with us… Maybe we are missing something…

  • Fer

    Should be ’super-clean’ installation because I even formated the drive… So I’m lost right now. I can format again or restore, but I wanted it to work properly hehe =)
    I have the dvd here, so I can reinstall again I guess

  • http://www.pawelmartuszewski.co.uk Pawel

    Hmm… maybe check MAMP version, restart servers before and after installing each component, type commands manually in your terminal… etc.

    PS. BTW my symfony installation took me 4 days lol… but once i figured out what need to be done, it took a minute…

    PS 2. The biggest problem with symfony is installation. Once you got everything installed it’s just a breeze and joy…

  • http://www.vijayinfo.in web design

    Your blog is very nice… i like your blog ….

  • Fer

    MAMP installed successfully (version 1.9). Also checked that /Applications/MAMP/bin/php5.3/bin/peardev has the peardev thing in it. But still says command not found when I tried that step to both discover symfony channel and install it…
    I will continue trying later, now I go to have dinner… sometimes programming (or the steps before programming) are exhausting -_-
    Thanks Pawel

    P.S. After PEAR and MAMP are installed, should I change anything in any php.ini ? Maybe this is important :S

  • http://www.pawelmartuszewski.co.uk Pawel

    Some blogs point out that you have to provide a path to your PEAR directory… but I didn’t have to modify anything there and it worked. Keep me updated Fer! I am interested in the outcome of your problem…

  • http://genericwpthemes.com Wordpress Themes

    Gratefulness you on your information.

  • Fer

    Well, finally made it Pawel =)
    So this is what I did.
    After installing MAMP, I just gave 755 permission to ‘/Applications/MAMP/bin/php5.3/bin/peardev’.
    Everything else was following your steps, so maybe it only was a permission issue with that folder. Now I am able to create project, to see all the images, and manage the databases =)

    Thanks for your help and tips!

    Now I will continue reading your SEO post ^^ It’s an interesting one too!

  • http://www.pawelmartuszewski.co.uk Pawel

    I am glad to hear that! Congrats! ;) Now time for Symfony Enjoyment!!

  • http://www.cna-trainingclass.com/passing-the-cna-exam/ online cna classes

    this post is very usefull thx!

  • http://ezinearticles.com/?Fat-Loss-4-Idiots---Best-Weight-Loss-Technique-With-a-Calorie-Shifting-Diet&id=3594558 Fat Loss for Idiots

    Many people will agree with this article whoever many other’s will disagree. Anyway I appreciate your hard work.

  • http://www.vainfotech.com Va Infotech

    nice works

    thanks.

  • http://www.dotpeak.com giorgia

    nice tips, thanks a lot

  • George

    sorry–basic question. still learning the ropes.

    when i try to install pear, typing php -q go-pear.php gives me php: command not found. Any ideas/suggestions?

    MAMP server was running when i tried this. thanks

  • http://www.pawelmartuszewski.co.uk Pawel

    i am guessing your pear installation did not succeed. try installing pear again…

  • dg

    Had the EXACT same problem as Fer – the system is a brand new macbook so its a clean install. I have updated to 10.6.6 so I’m not sure it thats a problem.

  • thecakeisalie

    Spent half the day trying to get Symfony running on my laptop (10.6.7). I tried 2 other methods – regular mysql/apache with entropy php and XAMPP – and both resulted in a weird 500 error. All useless until I read your guide. Thanks!!!!!

  •  
  •  
     
     
     
    Copyright © 2008 - 2012. All rights reserved.
    Pawel Martuszewski Design – Web Design Tutorials, operated by Direct Media Design