如何偵錯服務容器 & 列出服務
您可以使用主控台找出哪些服務已註冊到容器中。若要顯示所有服務(公開和私有)及其 PHP 類別,請執行
1 2 3 4
$ php bin/console debug:container
# add this option to display "hidden services" too (those whose ID starts with a dot)
$ php bin/console debug:container --show-hidden
若要查看可用於自動注入的所有類型列表,請執行
1
$ php bin/console debug:autowiring
偵錯服務標籤
執行以下命令以找出哪些服務使用特定標籤進行標記
1
$ php bin/console debug:container --tag=kernel.event_listener
也提供部分搜尋
1 2 3 4 5 6 7 8 9 10
$ php bin/console debug:container --tag=kernel
Select one of the following tags to display its information:
[0] kernel.event_listener
[1] kernel.event_subscriber
[2] kernel.reset
[3] kernel.cache_warmer
[4] kernel.locale_aware
[5] kernel.fragment_renderer
[6] kernel.cache_clearer
關於單一服務的詳細資訊
您可以透過指定服務 ID 來取得關於特定服務的更詳細資訊
1 2 3 4
$ php bin/console debug:container App\Service\Mailer
# to show the service arguments:
$ php bin/console debug:container App\Service\Mailer --show-arguments
本作品,包括程式碼範例,均依 Creative Commons BY-SA 3.0 授權條款釋出。