File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -850,9 +850,12 @@ This is mostly useful when you want to fetch services lazily::
850850 // ...
851851 }
852852
853- As a best practice, you should only create *private * services, which will happen
854- automatically. And also, you should *not * use the ``$container->get() `` method to
855- fetch public services.
853+ As a best practice, you should only create *private * services. This allows for
854+ safe container optimizations, e.g. removing unused services. You should not use
855+ ``$container->get() `` to fetch public services, as it will make it harder to
856+ make those services private later. Instead consider
857+ :ref: `injecting services <services-constructor-injection >` or using
858+ :doc: `Service Subscribers or Locators </service_container/service_subscribers_locators >`.
856859
857860But, if you *do * need to make a service public, override the ``public `` setting:
858861
You can’t perform that action at this time.
0 commit comments