Skip to content

Added a help note about glob patterns #8469

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
10 changes: 8 additions & 2 deletions service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,9 @@ key. For example, the default Symfony configuration contains this:

# the namespace prefix for classes (must end in \)
AppBundle\:
# accepts a glob pattern
# create services for all the classes found in this directory...
resource: '../../src/AppBundle/*'
# exclude some paths
# ...except for the classes located in these directories
exclude: '../../src/AppBundle/{Entity,Repository}'

# these were imported above, but we want to add some extra config
Expand Down Expand Up @@ -900,6 +900,11 @@ key. For example, the default Symfony configuration contains this:
// $this is a reference to the current loader
$this->registerClasses($definition, 'AppBundle\\Controller\\', '../../src/AppBundle/Controller/*');

.. tip::

The value of the ``resource`` and ``exclude`` options can be any valid
`glob pattern`_.

This can be used to quickly make many classes available as services and apply some
default configuration. The ``id`` of each service is its fully-qualified class name.
You can override any service that's imported by using its id (class name) below
Expand Down Expand Up @@ -1043,3 +1048,4 @@ Learn more

.. _`service-oriented architecture`: https://en.wikipedia.org/wiki/Service-oriented_architecture
.. _`Symfony Standard Edition (version 3.3) services.yml`: https://github.com/symfony/symfony-standard/blob/3.3/app/config/services.yml
.. _`glob pattern`: https://en.wikipedia.org/wiki/Glob_(programming)