How to Manage Configuration for Complex Backends
How to Manage Configuration for Complex Backends¶
The recommended way to start configuring your backend is to use the
config/packages/easy_admin.yaml file and put your configuration under the
easy_admin key. However, for medium-sized and large backends this
configuration can be very long and hard to maintain.
Splitting Configuration into Several Files¶
If your application keeps growing, it's better to split the configuration into different files.
Consider an application which defines the following configuration:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# config/packages/easy_admin.yaml easy_admin: site_name: '...' # ... design: # ... entities: Product: # ... User: # ... Category: # ... # ...
This configuration is going to be divided into four different files:
design.ymlfor design related configuration;
product.ymlfor the configuration related to
user.ymlfor the configuration related to
basic.ymlfor the rest of the configuration, including any entity different from
First, create a new
config/packages/easy_admin/ directory to store the new
files so they don't mess with the other Symfony configuration files. Then,
create the four files with these contents:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# config/packages/easy_admin/basic.yml easy_admin: site_name: '...' # ... # config/packages/easy_admin/design.yml easy_admin: design: # ... # config/packages/easy_admin/product.yml easy_admin: entities: Product: # ... # config/packages/easy_admin/user.yml easy_admin: entities: User: # ...
Beware that each configuration file must define its contents under the
key. Otherwise, Symfony won't be able to merge the different configurations.
This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.