Here is an example, taken from Symfony2 website, about defining a custom service (YAML notation):
services:
newsletter_manager:
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