Symfony 2 – Getting started a quick guide without vendors

Symfony Installation

To get started with Symfony 2, you will require a Web server (such as Apache) with PHP 5.3.2 or higher. If you want to use source control to store your project, this tutorial uses git.

Lets start by download the zip file from the Symfony website. make sure you select Symfony Standard 2.0.15 without vendors.

  1. unzip the into your web directory

    Symfony2 base install

    Symfony 2 Base install ~/Sites/sf2demo

  2. If you want to use Git to store your project create a new file .gitignore in your ~/Sites/sf2demo directory
  3. Copy app/config/parameters.ini to app/config/parameters.ini.dist. By doing this a new developer can quickly clone the repository, and add their own database passwords and settings, for their local machine.
  4. Init Git by running
  5. Add files to your local git repository
  6. Make the First Commit
  7. Now we can install the vendors
  8. Lock your current vendors installation
  9. Clean up the vendor install
  10. File permissions to allow cache and logs to be written

What are the vendors for?

The vendors directory contains all of source code [including the Symfony source code] to allow your application to work. Since Symfony2 is highly decoupled, it allows you to include and exclude particular modules or “bundles” that you do not need. for example symfony2 vendors come standard with Doctrine ORM, if you do not need a ORM Mapper of want to install a new one, simply remove or add the vendor in the deps file in ~/Sites/sf2demo. the deps.lock file makes sure that when you run

again, it will install the project specific vendor version defined in deps.lock. So if you want to upgrade a specific vendor, edit your deps.lock and deps files to set the version of the module you want to install, then run

to re-install your project specific vendors.

Virtual Host setup

This will allow you to setup a local domain name when viewing your site in a web browser, each operation system has it own directory structure and file locations, for most Linux and Mac OS X the directories will be the same or similar.

The Host File

  1. Edit the host file

    Your host file should look some think like this
  2. Add the highlighted text to the file

    vim hints: press i to start inserting text, use arrow keys to navigate, press esc to stop editing text, press : x [then enter] to save

The Virtual Host file

  1. Create a virtual host file
  2. Insert the virtual host information [make sure you use your site directory]
  3. Edit your http.conffile to include your virtual host

    Insert content in your httpd.conf if it does not exist [this is for Mac OS X Server]
  4. Restart Apache

The .htaccess file

  1. Edit your .htaccess file in ~Sites/sf2demo/web
  2. modify app.php to reflect app_dev.php


Viewing the site

Open up your browser and type enter the Url specified in your host and virtual host files sf2demo.local you should see the Symfony2 configuration page. you can now proceed to configure your application.

Symfony2 Setup page

Symfony2 Setup page

Tagged with: , , , , , , ,
Posted in PHP, symfony2

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">