Install Symfony 2.6


Install Composer:

First of all, these commands install composer on your system:

curl -sS | php
mv composer.phar /usr/local/bin/composer

Install Symfony:

Create your project

# composer create-project symfony/framework-standard-edition /path/to/webroot/Symfony '2.6.*'

Set folders rights

Go in your /path/to/webroot/symfony directory

# chmod -R 777 app/cache
# chmod -R 777 app/logs

Create an Admin Bundle :

# php app/console generate:bundle --namespace=Acme/AdminBundle --format=yml

Change routing namespace

add in app/config/routing.yml

    resource: "@AcmeAdminBundle/Resources/config/routing.yml"
    prefix: /admin

Create main layout

# touch src/Acme/AdminBundle/Resources/views/layout.html.twig

Then add:

<!DOCTYPE html>
        <meta http-equiv="Content-Type" content="text/html; charset={{ _charset }}"/>
        <meta name="robots" content="noindex,nofollow" />
        <title>{% block title %}{% endblock %}</title>
    <body class="page-header-fixed">
        {% block body %}{% endblock %}

Extend template

add at the beginning of html.twig files

{% extends "AcmeSiteBundle::layout.html.twig" %}
{% block body %}{% endblock %}

Generate entities

Generate the first entity

# php app/console generate:doctrine:entity
The Entity shortcut name: AcmeAdminBundle:Post
Configuration format (yml, xml, php, or annotation) [annotation]: yml
Do you want to generate an empty repository class [no]? yes

This should automatically creates the doctrine file/src/Acme/AdminBundle/Ressources/config/doctrine/Post.orm.yml

Activate translator

Uncomment :

# app/config/config.yml
translator: { fallback: "%locale%" }

Generate database


# php app/console doctrine:schema:update --force

Update entities

# php app/console doctrine:generate:entities Acme

Add public theme

You can copy images and css in the directory src/Acme/AdminBundle/Resources/public/assets, the run command:

# php app/console assets:install web --symlink


If you don’t want composer update to remove your parameters, add “keep-outdated”: true, in composer.json

"incenteev-parameters": {
    "file": "app/config/parameters.yml",
    "keep-outdated": true

Cache conflicts

To remove cache conflicts between “www-data” and other users, add at the begining of  app/console, and web/app_dev.php:

umask(0000); // Define a 777 permission

note: for security issues, you should remove these umask modifications from the prod server.

for prod, exectute:

# apt-get install acl

# HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
# sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
# sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs


Raphaël has written 45 articles

2 thoughts on “Install Symfony 2.6

  1. Raphaël says:

    The rights must be shared with your console user, and not www-data only. For exampe in case you need to clear cache (everytime you change the prod content).
    So, it is surely possible to manualy change permissions, but cache writing problems with symfony are such a pain, that I personnaly use the method below.

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> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>