Skip to content

Commit a69fa6a

Browse files
committed
Reword
1 parent dd5e047 commit a69fa6a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

service_container.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,12 @@ This is mostly useful when you want to fetch services lazily::
858858
// ...
859859
}
860860

861-
As a best practice, you should only create *private* services, which will happen
862-
automatically. And also, you should *not* use the ``$container->get()`` method to
863-
fetch private services.
861+
As a best practice, you should only create *private* services. This allows for
862+
safe container optimizations, e.g. removing unused services. You should not use
863+
``$container->get()`` to fetch public services, as it will make it harder to
864+
make those services private later. Instead consider
865+
:ref:`injecting services <services-constructor-injection>` or using
866+
:doc:`Service Subscribers or Locators </service_container/service_subscribers_locators>`.
864867

865868
But, if you *do* need to make a service public, override the ``public`` setting:
866869

0 commit comments

Comments
 (0)