Here is an example, taken from Symfony2 website, about defining a custom service (YAML notation):
services:
newsletter_manager:
you can also do this if you want to get details of a single service:
php app/console container:debug service_id
this will give you info on that service
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.
You can list services with
php app/console debug:container log
If you need more about some service you can use the help
php app/console debug:container log --help
you can use following command to get desired service details:
php app/console container:debug | grep service_name
you can use
php app/console container:debug
to get a list of all available public service IDs or
php app/console container:debug --show-private
to show both public and private service IDs
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