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

[DI] add docs for new namespace option #8310

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 1 commit
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
Next Next commit
[DI] add docs for new namespace option
  • Loading branch information
kbond committed Sep 5, 2017
commit 16e0cc74c06ead965e99c5e3a304496054f4ef65
25 changes: 25 additions & 0 deletions 25 service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,31 @@ them will not cause the container to be rebuilt.
means that all classes are "available to be *used* as services" without needing
to be manually configured.

.. sidebar:: The ``namespace`` Option

.. versionadded:: 3.4
The ``namespace`` option was added in Symfony 3.4.

When using the ``resource`` option in YAML, the namespace prefix can only be used once
per file when defining it as the ``id``. In order to have multiple definitions in the
same file with the same namespace prefix, you can use the ``namespace`` option. When
this option is used, the ``id`` can be anything as long as it is unique. For example,
you can define your services like this:

.. code-block:: yaml

# app/config/services.yml
services:
command_handlers:
namespace: App\Domain\
resource: ../../src/Domain/*/CommandHandler
tags: [command_handler]

event_subscribers:
namespace: App\Domain\
resource: ../../src/Domain/*/EventSubscriber
tags: [event_subscriber]

.. _services-explicitly-configure-wire-services:

Explicitly Configuring Services and Arguments
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.