This might be the easiest way to setup a Symfony dev environment. Say what you want of Mamp but it makes it dead easy to setup and manage your localhost server. Mamp is an excellent development environment especially if you are a newbie just starting off, and is definitely the simplest way to setup a localhost development environment for a Symfony project. I am using MampPro, which costs $59 and has a 30 day trial.
What is Mamp
MAMP installs a local server environment on OSX. It comes with Apache, MySQL ready to run. The Pro version is the commercial version of Mamp comes with SSL support, PHPMyAdmin, Allows you to switch between multiple versions of PHP and has easy access to your error logs. You can download Mamp at http://www.mamp.info/
Setting up Mamp
When you start Mamp up you need to configure a few things to make it work with a Symfony2 project. First, select the ports you want Apache to run on. I chose the default ports. You will need to make sure Websharing is turned off on your Mac (System Preferences -> Sharing).
Set the PHP Version
Click on the PHP tab and set the PHP version to 5.3.x. Since your will be running a Symfony 2 project you will need 5.3.X
Setup your hosts and vhosts file
Before doing this step, you will need to put your symfony files in place. I downloaded a fresh distribution from http://symfony.com/download and dropped the directory in ~/Sites since I keep all my sites there. I then renamed my “Symfony 2″ directory which I just downloaded to “testproject”.
1) Go back into Mamp, click on the “Hosts” tab.
2) Click on the “+” icon to setup a new host. This will setup your hosts and virtual hosts configurations.
3) Set the Server Name. This will be how you access the server. In this case your will type in http://testproject in your browser to access this site.
4) Set the Disk Location. NOTE, since you are setting up a Symfony project you will need to set the “disk Location” (AKA: Document Root) to the /web directory as shown above.
The app/cache and app/logs directories must be writable both by the web server and the command line user. You need to set these up. Log into your Terminal app and navigate to the directory where you installed Symfony. In my case:
Then you need to setup permissions for the correct users. Run:
sudo chmod +a "www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
If all is done right you should be read to go. Type in your browser:
And you should see:
That’s it. Your local dev environment is setup and you are ready to start. Let the fun begin :)