Setting up a Symfony2 Project from Total Scratch

Let's go through how we will setup a Symfony2 project from start to beginning! We will be using nice hipster stuff that employers love on automated resumé buzzword screeners (throw a wrench in their system! \o):

  • Vagrant
  • Composer
  • Symfony2 (!)
  • LAMP

This is mostly for myself to reference for other projects, such as this particular one, so if I am missing something, it maybe because I am only writing this for myself. Feel free to contribute, however!


Installing Vagrant

  1. Install the latest version of Vagrant through their downloads page. The latest version fixed that unnecessary issue of manually setting up your private/public keys. Finally, no need to spend five hours setting up Vagrant! Only four.

  2. Since I already have an existing VirtualBox with my choice of virtualization OS cached, I simply need to use the Vagrantfile that I've commited to my scripts repo. Note: Skip this step if you're doing a Symfony 2 project, as the next step will contain the necessary Vagrantfile for Symfony 2.

Setting Up Vagrant with your Tech Stack Stuff using Provisioning (the cool way)

  1. git clone

  2. Take the /provisioning/ folder and Vagrantfile file and put it into your project root directory /YourProject/.

  3. Uncomment APPNAME in line 6 of the Vagrantfile and assign your project's name to it.

  4. Change ' "forwarded_port", guest: 80, host: XXXX' to your needs, especially if you have multiple projects

  5. Run vagrant up --provision

The above steps would automagically install all the necessary things onto your Vagrant machine such as PHP, Apache5, and more. Automagically!

Setting Up Vagrant with your Tech Stack Stuff Manually (the un-cool way)

The above step replaces this step, but I am keeping this part so the curious ones like me can understand what is happening during the automation process

Digital Ocean has a really good article on setting up your dev stack aka LAMP.

Note: I condensed Digital Ocean's article and put it here. Please visit their article as well - they did a really good job going through the steps.

The gist is, while in your Vagrant VM:

  1. Update your repo using:

    apt-get update

  2. Install Apache using:

    apt-get install apache2

  3. You can now check if Apache is up and running by going to localhost:xxxx with xxxx being the host port that you've set in your Vagrantfile earlier.

  4. Install MySQL using:

apt-get install mysql-server

  1. At this point MySQL will ask you for a username and password combo. Out of pure laziness just put in root/root. You can easily change this later.

  2. Install PHP:

apt-get install php5 php-pear php5-mysql

  1. Restart Apache2 to see your hard work!

service apache2 restart


Get the Composer Installer within your Vagrant Machine

  1. Grab the Composer installer composer.phar from this place:

curl -sS | php

  1. Symfony might scream at you in a later step if you keep composer.phar in the root directory, so for precautionary sake, put composer.phar inside /tmp/ like this:

mv composer.phar /tmp

Symfony 2

  1. . Good job for making this far! You're getting close. Finally, install Symfony2 using an already-configured package from We-Bridge:

php /tmp/composer.phar create-project webridge/framework-standard-edition . -vvv

  1. Symfony2 is going to put a lot of files into your project directory, so we can now setup the .gitignore which I have put in my scripts repo. Don't forget to rename the .symfony2_gitignore to .gitignore.

I haven't gone this far yet. I'll update the article as I go.

This article was mirrored from my's Wiki page on Github, with technical consulting from my coworker, our company's senior software architect, Allan Simon.