× Toggle menu

How To Install Symfony2 on Ubuntu 14.04

This is a guest post by Antonio Peric who is the CEO of Locastic, co-founder of SHIFT Conference and co-founder of Symfony Croatia User Group.

Over the last few weeks, we have announced a set of new predefined development environments (DevBoxes), one of them being Symfony2. This will save you a lot of time because you no longer need to set up your own Symfony2. However, in case you do, we wanted to show you how to do it on your own.

What is Symfony?

Symfony2 is one of the most popular PHP frameworks today. There are some pretty amazing projects that make use of Symfony2, including; Drupal 8, eZpublish, Sylius, OroCRM, even Magento uses some of Symfony2 components (for the full list, visit http://symfony.com/projects). Also, some very popular frameworks like Laravel are built on top of Symfony2 components.

Setup

First of all, before proceeding with this part of the tutorial, make sure your Trusty Tahr instance is configured with either LAMP (Linux, Apache, MySQL, PHP) . If you don't have the Linux, Apache, MySQL, PHP installed please do that first.

There are multiple ways to install Symfony2, but using Composer is arguably the easiest one.
First, install Composer. You can install it locally or globally. For the purposes of this tutorial, I will demonstrate how to do it locally.

Download the composer with curl:

curl -sS https://getcomposer.org/installer | php

or if you don’t have curl:

php -r "readfile('https://getcomposer.org/installer');" | php

This should give you a composer.phar file which completes our local installation of Composer.
Now you can move it to /usr/bin and rename it to Composer, but I’ll leave this step to the more savvy among you.

Symfony Installation

Now let’s initialize your Symfony2 application:

php composer.phar create-project symfony/framework-standard-edition my_project_name

If you are a beginner, during the installation choose "yes" to install AcmeBundle. There you’ll have examples of how your bundle should look like.

After it’s done, the final step will be to symlink the web directory to your public_html directory.
To do that, simply write:

ln -s my_project_name/web /path/to/public_html

Congratulations, you’ve just finished the basic installation of Symfony2! Now if you go to the URL of your localhost, you will see the Symfony2 demo.

Ready to go!

Setting up a Symfony2 application in Codeanywhere is really simple. It is literally two clicks with your mouse and one small change in the php.ini file. First thing that comes to mind is how easy it will be to set up any of my BitBucket projects (https://blog.codeanywhere.com/bitbucket-embraces-the-cloud-ide/) and make necessary changes without the hassle of pulling files locally, building machines and other things. Don't forget that I can do all of this anywhere, even on my iPad :)

Ready to start coding from anywhere?

Join the growing community of over ... businesses and professionals that already use Codeanywhere on a daily basis, and you can start coding from anywhere for free.

Sign up for free