Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a list of Symfony2 default container services?

Here is an example, taken from Symfony2 website, about defining a custom service (YAML notation):

services:     newsletter_manager:         class:     %newsletter_manager.class%         arguments: [@mailer, @templating] 

Is there a list of default Symfony2 service objects that can be injected into a custom service as parameters (like @mailer, @templating, @doctrine)?

I know that they come from the Container (which is available, for example, in each Controller class). I've tryed to dump all services, but i'm looking for a more detailed list:

php app/console container:debug  logger container Symfony\Bridge\Monolog\Logger mailer container Swift_Mailer translator n/a alias for translator.default ... 
like image 309
Polmonino Avatar asked Feb 27 '12 23:02

Polmonino


2 Answers

The command line php app/console container:debug shows the list of services you can inject into another service or get from a Controller with Controller::get($serviceName).

This list shows only public services. Add the option --show-private into display private services. Private services can only be injected in another service, not accessed from a Controller or any ContainerAware...

EDIT: From Symfony 2.7, use debug:container instead of container:debug

like image 62
AlterPHP Avatar answered Sep 19 '22 06:09

AlterPHP


The WebProfilerExtraBundle is very useful for this.

It also adds some details about routing, assetic and twig that are very helpful. As a someone learning to think in Symfony, I REALLY like this bundle.

like image 31
Icode4food Avatar answered Sep 20 '22 06:09

Icode4food