Is there a list of Symfony2 default container services?

前端 未结 6 479
小蘑菇
小蘑菇 2020-12-22 21:56

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

services:
    newsletter_manager:
                 


        
相关标签:
6条回答
  • 2020-12-22 22:20

    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

    0 讨论(0)
  • 2020-12-22 22:27

    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.

    0 讨论(0)
  • 2020-12-22 22:29

    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
    
    0 讨论(0)
  • 2020-12-22 22:31

    you can use following command to get desired service details:

    php app/console container:debug | grep service_name
    
    0 讨论(0)
  • 2020-12-22 22:32

    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

    0 讨论(0)
  • 2020-12-22 22:35

    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

    0 讨论(0)
提交回复
热议问题