Skip to content

Commit

Permalink
minor #3727 Added a note about inlined private services (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #3727).

Discussion
----------

Added a note about inlined private services

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | 2.3+
| Fixed tickets | -

When you define private services that are used just as arguments for another service, Symfon2 doesn't define them as services, but inlines them in the other service definition. This slightly improves the performance of the container, but it's confusing for Symfony beginners because the private services aren't displayed by the `container:debug` command even when using the `--show-private` option:

```
$ php app/console container:debug --show-private
```

Commits
-------

15a7be0 [book] [service_container] added the title of a cross reference
835b52f Emphasized the fact that this only applies when the private service is used as argument for a single service
04cb9d4 Added a note about inlined private services
  • Loading branch information
weaverryan committed Apr 2, 2014
2 parents abca098 + 75d06e6 commit 44c6273
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions book/service_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,13 @@ By default only public services are shown, but you can also view private service
$ php app/console container:debug --show-private
.. note::

If a private service is only used as an argument to just *one* other service,
it won't be displayed by the ``container:debug`` command, even when using
the ``--show-private`` option. See :ref:`Inline Private Services <inlined-private-services>`
for more details.

You can get more detailed information about a particular service by specifying
its id:

Expand Down
2 changes: 2 additions & 0 deletions components/dependency_injection/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ However, there are use-cases when you don't want a service to be public. This
is common when a service is only defined because it could be used as an
argument for another service.

.. _inlined-private-services:

.. note::

If you use a private service as an argument to only one other service,
Expand Down

0 comments on commit 44c6273

Please sign in to comment.