New in Symfony 4.1: Hidden services

综合编程 2018-05-16 阅读原文

Contributed by

Nicolas Grekas in #26921 .

In Symfony 3.4 we made all Symfony services private by default . This is generally better and makes applications more robust (as explained in the previous post) but it also has some drawbacks.

The debug:container command for example hides the private services by default, so it's no longer useful to list the services available in your application. That's why in Symfony 4.1 we've changed the debug:container command to show the private services by default and we've also deprecated the --show-private option.

Independently from being public or private, sometimes it's useful to hide some services from the debug:container listing because they are not intended for being used by the developers. In those cases, you can add a dot character ( . ) at the beginning of the service ID to turn it into a "hidden service".

Hidden services behave like the rest of services, except for the fact that they are not included by default in the output of debug:container , so you must add the new --show-hidden option to show them:

$ ./bin/console debug:container --show-hidden

We are already using this feature to hide some internal Symfony services created by theLock component.

Symfony Blog

责编内容by:Symfony Blog阅读原文】。感谢您的支持!


Symfony2 doctrine cascade delete child relation Consider a Parent with 0..n Child's. When I remove a Child from the Parent, and persist the Parent object, I need the Ch...
SymfonyCon Lisbon here we come: schedule part 1! The international Symfony conference will be organized from December 6th to 8th at the Lisbon Marriott Hotel , in...
Tomas Votruba: 4 Ways to Speedup Your Symfony Deve... In a new post to his site Tomas Votruba covers a recent release of the " symplify/package-builder " package f...
Creating and updating Symfony projects much faster A few years ago, we introduced the Symfony Installer as the fastest way to create new Symfony projects. While Com...
Symfony / Doctrine – query date valu... I have two entities payroll week and payroll period, want to write a query that checks if the start date and end date...