Creating a New Symfony Project

This tutorial aims to teach you how to get up and running with Symfony with minimal effort. I assume that you already have Apache httpd running and that mod_php is built in it. I also assume that the php command is available in your environment.

Let's create a new directory somewhere in our Apache DocumentRoot for our project and go into it.

$ mkdir symfonytutorial
$ cd symfonytutorial

Now we need to download composer. To make it simple, we just download the latest snapshot into our current directory. If you don't have curl available, you can use wget or just download the .phar using your browser and move the file into your symfonytutorial directory.

$ curl -O https://getcomposer.org/composer.phar
$ chmod +x composer.phar

Now to install Symfony into a Symfony directory in our current directory.

$ ./composer.phar create-project symfony/framework-standard-edition Symfony

Then we allow Apache to write files into Symfony's cache and logs directories.

$ chmod -R a+w Symfony/app/cache Symfony/app/logs

After doing so, we can point our browser to our Apache instance, specifically to where we placed our Symfony installation. I made mine available as

http://localhost/symfonytutorial/Symfony/web/app_dev.php

You should see Symfony's default Welcome page.

There's a bundle included in the Symfony installation. Try to point your browser to

http://localhost/symfonytutorial/Symfony/web/app_dev.php/demo

and you should see 3 links. Click on the Hello World link to see the obligatory Hello World page. Notice that the URL now looks like

http://localhost/symfonytutorial/Symfony/web/app_dev.php/demo/hello/World

Replace World in the URL with your name and see the text on the page change!

On my next post, we'll learn the basics of creating a Bundle to hold our Models, Views, and Controllers.

blogroll

social