Symfony Standard: Quick Install

Install Git

If your system has a package manager, you should use it! It's much easier than dealing with configuring and making the package yourself.

Mac OSX Brew
brew install git
apt-get install git-core
yum install git

Install Composer

This is the quickest way to get composer installed and globally accessible. It does however require curl

curl -sS | php -- --install-dir=bin

Apache Document Root

We'll create the document root to put our Symfony application and get it prepared for Apache. I'm using /var/www to start with in this example, this value can be anything you need it be on your computer. I'm also using the www-data user as the user who apache invokes. This can be a variety of things in various systems, you'll need to figure out what user is being used on your server.

mkdir /var/www mkdir /var/www/symfony chown www-data:www-data /var/www/symfony

Git Clone Symfony Standard

Use git to clone the symfony standard library into your created document root.

git clone -b 2.3 \ \ /var/www/symfony/version1.0

Why version1.0 when we just cloned branch 2.3? Well because this is our project now, Symfony is an application framework and the standard edition is set up for you to start coding straight into the src/ directory. This will really show it's strength when we go to deploy the next version of this project.

Now that we have cloned Symfony standard, we'll set up a symlink that we'll use later to minimize server downtime during new deployments.

ln -s /var/www/symfony/version1.0 \ /var/www/symfony/current

Apache Virtual Host

It's best practice to give your sites their own virtual host. It keeps the URLs clean and consistent with the production environment and can be really beneficial when it comes to subdomains and various environments such as staging and development.

Modify your hosts file to give your server it's own domain name. Add this line to your /etc/hosts file. The IP is your local system, if you're working with an external web server you'll need to use that IP. The hostname can be anything, however the hosts file takes precedence over other DNS providers, don't overwrite Google!

Now that we have a server name and a document root we can start to work with our apache configuration. In many environments putting a file in /etc/apache/conf.d directory will include it in the main httpd.conf file. Others can use sites-enable in place of conf.d but basically do the same thing.

<Directory /var/www/symfony/*/web> AllowOverride all </Directory> <VirtualHost *:80> DocumentRoot /var/www/symfony/current/web ServerName </VirtualHost>

After you've made the change you'll have to restart apache

apachectl restart

Run Composer

Composer really makes this part easy, composer and Symfony standard's post installation scripts handle the installation of Symfony's core components as well as all of the third party libraries that Symfony standard relies on, such as Doctrine, Swiftmailer, Monolog et al.

Composer uses a composer.json file to determine what needs to be done, navigate to the directory we deployed the symfony installation and run the following.

cd /var/www/symfony/version1.0 composer install

Finishing Touches

After composer has installed it's set up for the most part however I like to go back and run a few more commands to make sure my development environment is all set.

cd /var/www/symfony/version1.0 app/console cache:clear app/console assets:install web --symlink app/console assetic:dump

When that is finished you should be all set to test out the server by entering this URL into your browser.