Documentation » Admin

10. Preview Mode »

« 8. Advanced configuration

9. Annotations

All annotations require jms/di-extra-bundle, it can easily 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
            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:

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

9.1. Define Admins

All you have to do is include SonataAdminBundleAnnotations and define the values you need.


namespace AcmeBundle\Admin;

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

 * @Sonata\Admin(
 *   class="AcmeBundle\Entity\MyEntity"
 * )
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!