Documentation » Admin

10. Preview Mode »

« 8. Advanced configuration

This Page

10. Preview Mode »

« 8. Advanced configuration

9. Annotations

All annotations require jms/di-extra-bundle, it can be installed by composer:

composer require jms/di-extra-bundle

if you want to know more:

The annotations get registered with JMSDiExtraBundle automatically if it is installed. If you need to disable this for some reason, you can do this via the configuration:

  • YAML
    # config/packages/sonata_admin.yaml
            enable_jms_di_extra_autoregistration: false


Starting with version 4.0, SonataAdminBundle will no longer register annotations with JMSDiExtraBundle automatically. Please add the following to your config.yml to register the annotations yourself:

# config/packages/jms_di_extra.yaml

        - JMS\DiExtraBundle\Annotation
        - Sonata\AdminBundle\Annotation

9.1. Define Admins

All you have to do is include Sonata\AdminBundle\Annotation and define the values you need:

namespace App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Annotation as Sonata;

 * @Sonata\Admin(
 *   class="App\Entity\MyEntity",
 *   id="service id (generated per default)",
 *   managerType="doctrine_mongodb (orm per default)",
 *   baseControllerName="Sonata\AdminBundle\Controller\CRUDController",
 *   group="myGroup",
 *   label="myLabel",
 *   showInDashboard=true,
 *   translationDomain="OMG",
 *   pagerType="",
 *   persistFilters="",
 *   icon="<i class='fa fa-folder'></i>",
 *   keepOpen=false,
 *   onTop=false
 * )
final class MyAdmin extends AbstractAdmin


If you need to define custom controllers you can also use jms/di-extra-bundle by using the DIService annotation.

Found a typo? Something is wrong in this documentation? Just fork and edit it!