Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 16e0cc7

Browse filesBrowse files
committed
[DI] add docs for new namespace option
1 parent d410c46 commit 16e0cc7
Copy full SHA for 16e0cc7

File tree

1 file changed

+25
-0
lines changed
Filter options

1 file changed

+25
-0
lines changed

‎service_container.rst

Copy file name to clipboardExpand all lines: service_container.rst
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,31 @@ them will not cause the container to be rebuilt.
923923
means that all classes are "available to be *used* as services" without needing
924924
to be manually configured.
925925

926+
.. sidebar:: The ``namespace`` Option
927+
928+
.. versionadded:: 3.4
929+
The ``namespace`` option was added in Symfony 3.4.
930+
931+
When using the ``resource`` option in YAML, the namespace prefix can only be used once
932+
per file when defining it as the ``id``. In order to have multiple definitions in the
933+
same file with the same namespace prefix, you can use the ``namespace`` option. When
934+
this option is used, the ``id`` can be anything as long as it is unique. For example,
935+
you can define your services like this:
936+
937+
.. code-block:: yaml
938+
939+
# app/config/services.yml
940+
services:
941+
command_handlers:
942+
namespace: App\Domain\
943+
resource: ../../src/Domain/*/CommandHandler
944+
tags: [command_handler]
945+
946+
event_subscribers:
947+
namespace: App\Domain\
948+
resource: ../../src/Domain/*/EventSubscriber
949+
tags: [event_subscriber]
950+
926951
.. _services-explicitly-configure-wire-services:
927952

928953
Explicitly Configuring Services and Arguments

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.