Chapter 2. Your First Backend

2.x version
Maintained

Chapter 2. Your First Backend

Creating your first backend will take you less than 30 seconds. Let's suppose that your Symfony application defines three Doctrine ORM entities called Product, Category and User.

Open the config/packages/easy_admin.yaml file and add the following configuration:

1
2
3
4
5
6
7
# config/packages/easy_admin.yaml
easy_admin:
    entities:
        # change the following to the namespaces of your own entities
        - App\Entity\Product
        - App\Entity\Category
        - App\Entity\User

Congratulations! You've just created your first fully-featured backend! Browse the /admin URL in your Symfony application and you'll get access to the admin backend:

Default EasyAdmin Backend interface

Note

If the interface of your backend displays translation keys instead of the actual contents, make sure that the translator service is enabled:

1
2
3
4
# config/packages/translation.yaml
framework:
    translator:
        fallbacks: [ "en" ]

Expanded Configuration Format

This simple backend uses the shortcut configuration format, but for real backends, you must use the extended configuration syntax instead, which allows to configure lots of options for each entity:

1
2
3
4
5
6
7
8
9
# config/packages/easy_admin.yaml
easy_admin:
    entities:
        Customer:
            class: App\Entity\Customer
        Order:
            class: App\Entity\Order
        Product:
            class: App\Entity\Product

Entities are configured as elements under the entities key. The name of the entities are used as the YAML keys. These names must be unique in the backend and it's recommended to use the CamelCase syntax (e.g. BlogPost and not blog_post or blogPost).

The only required option in this configuration format is called class and defines the fully qualified class name of the Doctrine entity managed by the backend.


Next chapter: Chapter 3. Basic Configuration

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.