Prerequisites

Symfony2 requires at least PHP 5.3.2. If your Mac is not ready, you can follow these instructions.

And make sure Git is installed on your system.

Sandbox and generators

There are three ways to get the initial structure of a new Symfony2 project:

Currently, the recommended way is the Sandbox (Symfony Bootstrapper is still in development, undocumented and can be buggy).

Symfony2Project is an alternative created by Bertrand Zuchuat. You should give it a try.

Creating a new project with the Sandbox

To get the Sandbox, go in your development workspace and grab the source:

cd /path/to/your/workspace
git clone https://github.com/symfony/symfony-sandbox.git

For example, my development workspace is $HOME/Code/PHP:

cd $HOME/Code/PHP
git clone https://github.com/symfony/symfony-sandbox.git

Create a copy of the symfony-sandbox folder with the name of your project:

cp -r symfony-sandbox project

For example, I name my project sf2project:

cp -r symfony-sandbox sf2project

Fix some permissions for the cache and logs folders:

cd project
chmod -R 777 app/cache
chmod -R 777 app/logs

With my sf2project:

cd sf2project
chmod -R 777 app/cache
chmod -R 777 app/logs

Create a VirtualHost (instructions) with a similar configuration:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/absolute/path/to/your/project/web"
    ServerName project.localhost
    <Directory "/absolute/path/to/your/project/web">
        Options Indexes FollowSymlinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog "logs/project-error_log"
    CustomLog "logs/project-access_log" common
</VirtualHost>

Example of my sf2project:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/Users/gilles/Code/PHP/sf2project/web"
    ServerName sf2project.localhost
    <Directory "/Users/gilles/Code/PHP/sf2project/web">
        Options Indexes FollowSymlinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog "logs/sf2project-error_log"
    CustomLog "logs/sf2project-access_log" common
</VirtualHost>

Restart the server.

Open your browser and go to the URL: http://project.localhost. You should see the “Congratulations” page.

To check if everything is correctly installed and configured, go the URL: http://project.localhost/check.php. If you see green everywhere, you won. Otherwise, fix any problem that it finds.