Tag Archive: sonata

Install and configure Symfony 2 and Sonata bundle

I found some bugs and inconsistencies while trying to install those 3 bundles by the book, so I decide to create that small tutorial.

What we gonna install:

  • Symfony Framework
  • SonataAdminBundle
  • SonataDoctrineORMAdminBundle
  • SonataEasyExtendsBundle

First we start by installing the Symfony Framework

1
composer create-project symfony/framework-standard-edition

Now we jump to the sonata bundle

1
composer require sonata-project/admin-bundle

Choose one connection, I use mysql so I need to install the SonataDoctrineORMAdminBundle

1
composer require sonata-project/doctrine-orm-admin-bundle

Activate the bundles

SonataAdminBundle

AppKernel.php

1
2
3
4
5
6
7
/* Sonata */
new SymfonyBundleSecurityBundleSecurityBundle(),
new SonataCoreBundleSonataCoreBundle(),
new SonataBlockBundleSonataBlockBundle(),
new KnpBundleMenuBundleKnpMenuBundle(),
new SonataDoctrineORMAdminBundleSonataDoctrineORMAdminBundle(),
new SonataAdminBundleSonataAdminBundle(),

config.yml

1
2
3
4
5
6
sonata_block:
  default_contexts
: [cms]
  blocks
:
   # Enable the SonataAdminBundle block
    sonata.admin.block.admin_list
:
      contexts
:  [admin]

routing.yml

1
2
3
4
5
6
7
8
admin:
    resource
: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix
: /admin

_sonata_admin
:
    resource
: .
    type
: sonata_admin
    prefix
: /admin

With this done, you should see a layout like this one in your site.

Sonata admin dashboard

At this moment we have the Sonata Admin Bundle configured in our site. We gonna process now with the Easy Extend Bundle then we end with the User Bundle.

EasyExtendBundle

Pretty simple to configure this bundle, start to download the bundle and activate the bundle in the AppKernel file.

1
php require sonata-project/easy-extends-bundle

AppKernel.yml

1
new SonataEasyExtendsBundleSonataEasyExtendsBundle(),