Skip to content

Updated the service naming conventions for modern Symfony apps #9215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions contributing/code/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,17 @@ Naming Conventions
Service Naming Conventions
~~~~~~~~~~~~~~~~~~~~~~~~~~

* A service name contains groups, separated by dots;
* A service name must be the same as the fully qualified class name (FQCN) of
its class (e.g. ``App\EventSubscriber\UserSubscriber``);

* The DI alias of the bundle is the first group (e.g. ``fos_user``);
* If there are multiple services for the same class, use the FQCN for the main
service and use lowercased and underscored names for the rest of services.
Optionally divide them in groups separated with dots (e.g.
``something.service_name``, ``fos_user.something.service_name``);

* Use lowercase letters for service and parameter names (except when referring
* Use lowercase letters for parameter names (except when referring
to environment variables with the ``%env(VARIABLE_NAME)%`` syntax);

* A group name uses the underscore notation;

* Add class aliases for public services (e.g. alias ``Symfony\Component\Something\ClassName``
to ``something.service_name``).

Expand Down