Guide: Installation of Symfony CMS project (with SonataPageBundle and FosUserBundle)

Rate this post


In this tutorial we will install a mini CMS site based on Symfony 2.5 and SonataAdmin (with major part of it’s bundles).

Also you will find a step by step code on Github Repository

Installation of composer.phar

If you don’t have composer installed globaly on your system, you can install a local version in this way

or (if you don’t have curl)


Installation of Symfony Standard

In this guide I will use partitular flag which will enable to generate symfony 3 directory structure. This question has been suppressed in latest version of symfony, but you can bring it back by using flag SENSIOLABS_ENABLE_NEW_DIRECTORY_STRUCTURE. I prefer this new structure because I think that it’s much more cleaner and reasonable than v2.

Main differences between v2 and v3 is that

  • console and other scripts have been moved to /bin folder (so you will need to modify major part of app/console commands from another tutorials)
  • all temporary folders has been moved to /var

Run in your root directory


Now move newly created files

Optional: add following two lines to .gitignore

Open app/config/parameters.yml and set valid doctrine orm credentials if you haven’t entered them in previous wizard.

Now fix app_dev.php so that you can open it from any ip (optional). Just remove following piece

Let’s check that all requisites has been sotisfied

Enable translation in config.yml

Some Composer tweaks

When composer updates vendors, it makes  a hard copy of  static (images, js, css) files in /web/bundles. If you are using Linux, you can tell composer to use symbolic links instead with directive symfony-assets-install (inside extra section). Just edit your composer.json.

Installation of SonataAdmin

Install latest code (dev-master)

Install doctrine orm admin connector

Modify your AppKernel

If everything went fine, on you will see an empty administration dashboard. There is nothing yet, we will get there. Now it’s time to install some other useful packages.

Simplethings Entity Audit Bundle

add to require section of composer.json

Register new bundle in AppKernel.php

Sonata User Installation with FOSUserBundle

Add to your composer’s require section

Then modify config.yml and add following configs for doctrine:

Note two things here:

  1. auto_mapping:true has been moved under entity_managers:default
  2. ApplicationSonataUserBundle is commented (while in official documentation is not). The thing is that we still didn’t extend SonataUserBundle, and that row would provoke an error. We will enable it later.

Continuing with editing of config.yml

Add to your routing.yml

then security.yml

Install new Bundles

Add to your AppKernel.php new bundles

 Now let’s extend Sonata User Bundle

Add new extended bundle to your AppKernel.php

in config.yml change user_class and group_class 

and decomment ApplicationSonataUserBundle: ~ under node doctrine Update database structure

User creation

Now it’s time to create our user:

Now you can go to http://yourhost/admin (you should see login box) and use combo admin:qwerty for login. Also on a dashboard you should see two new entities, Users and Groups

Installation of SonataCacheBundle

Add to composer.json

In config.yml append to the end of file

(as always check official documentation for clarifications if needed) Add routings to routing.yml

Update autoload.php

Add new bundle to AppKernel.php

Installation of Sonata Seo Bundle

add to composer.json

Register new bundle in AppKernel.php

append to config.yml

 Installation of Sonata Notification Bundle

Add repository to composer.json 

new bundle to AppKernel.php

and automappings to config.yml

run composer update

Now we can proceed with extending of  SonataNotificationBundle.


Register your new bundle in AppKernel.php

Add automapping in config.yml


Installation of Sonata Page Bundle and Symfony Cmf Routing Bundle

Now we have all dependencies and we can finally we can proceed with installation of sonata page bundle

Add to your composer.json

and run composer.phar update

Enable bundles in AppKernel.php

Edit config.yml

Append to routing.yml

Edit security.yml

Now we are ready to extend our PageBundle

Decomment ApplicationSonataPageBundle: in config.yml (doctrine->orm->entity managers->default->mappings)

Add newly create bundle to AppKernel.php

Update your database

 Default Site Creation

Now we need to create default site (otherwise you can receive some errors in admin->pages section).

you should see following output (more or less)

Run last two commands (be sure to replace app/ with bin/ if you are using symfony 3 directory structure).

You may also like...

Lascia un Commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *

È possibile utilizzare questi tag ed attributi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">