Symfony2: Installation

The official installation doc is http://symfony.com/doc/current/book/installation.html.

As a best practice, don’t install symfony in MAC or Windows, install in Linux and use Linux for development because you will be using Linux for hosting.

For consistency in development, develop in virtual machine. The spec of the virtual machine should be the same as the production server. The best way to do it is to use vagrant.

In this example, we will create a ficticious project called SongBird. First of all, we need to create a portable and consistent development environment so that we speak the same language. This is also important if you decide to outsource the development in the future. Next we need a tool like puppet to configure automate software configuration.

To get started, let’s get this symfony repo – https://github.com/bernardpeh/songbird

git clone https://github.com/bernardpeh/songbird
vagrant up

This will take a long time… most of the alerts you see in the screen is harmless. this is a once off setup. Enter root password when prompted.

According to the doc, you can choose a number of ways to install symfony, most people chose the composer method. Don’t use composer or manually download, install the symfony command line instead.

vagrant ssh
# you are now in the virtual machine
sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

To create a new project call “songbird” using the long term support version,

cd /vagrant
symfony new songbird lts
cd songbird
sed "s/'127.0.0.1'/'127.0.0.1','33.33.33.1'/g" -i web/app_dev.php
# check that all requirements met
php app/check.php
# you should see that the config has passed

In your parent host, we need to add get songbird.dev to be pointing to the vm. add this to your host file.

33.33.33.100 songbird.dev www.songbird.dev

In your parent, Test your site by going to http://songbird.dev/app_dev.php/app/example

If you see the word “Homepage”, everything is good.

Now let us commit everything before we proceed.

git init .
git add .
git commit -m"init commit"

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Sitecritic.net Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.