Maxime Bernard's blog

Symfony on Mac OS X

I recently bought a Macbook Air 13” for 2 reasons: 

  1. I wanted to develop more Iphone apps since I know more about it ! (I’ll probably write an article to talk more about that)
  2. I wanted to have a UNIX-like OS to develop my websites. I’m currently working on a personal project with some friends and I used to develop on Ubuntu in a VM VirtualBox. It’s pretty useful but it’s not as much productive and convenient as a real UNIX environment if you want to develop with Symfony.

But the funny thing was first to install the web environment to develop. The “apt-get”-like on Mac OS is called MacPorts, such as “ports” on every BSD-like OS. However, if you are used to “apt-get install lamp-server^”, get out ! MacPorts is a lot more complicated than that ! You’ll have to compile your sources and configure them one by one, etc… If you have 1 or 2 days to lose on this, have fun !

So I took MAMP. MAMP is known for not being as much configurable as would be your own AMP environment. But you’ll see in the end of this article that it’s not true ! (or I didn’t find the limit…)

First problem in my way to make my symfony project work on my laptop was configuration problem. Be careful, Mac OS has is own installation of PHP. go check in “/etc/php.ini.default”. You can use this one when you’ll have problems with the default one in MAMP.

The second thing to know is that the apache server created by MAMP does not use the same php.ini than the PHP CLI (e.g. “php -v” in your console). So when you’ll try commands like “./symfony doctrine:build —all —and-load”, even if everything goes well, it does not mean the apache server will tell you the same.

So, don’t forget to add this in your sh config file:

export PATH=/Applications/MAMP/bin/php5/bin:$PATH

 Then, you should have the same configuration file for both PHP Web and CLI.

Finally, I also had this error

Couldn’t locate driver named mysql

In my case, the problem was that I used the default /etc/php.ini.default as my new php.ini so I had to had these lines:

; Extensions

extension=pdo_mysql.so

extension=… .so

You can take a look in /Applications/MAMP/conf/php5.2/php.ini if you (just like me) overwrote it.

For me, everything works fine and should go smoothly now !

Hope it saved your time !

Merry Christmas !


To Tumblr, Love PixelUnion