egulias / tag-debug-command-bundle
Symfony 2 的控制台命令,用于调试服务标签
1.0.0
2014-08-27 22:51 UTC
Requires
- egulias/tag-debug: ~1.0
- symfony/console: ~2.3
- symfony/dependency-injection: ~2.3
- symfony/framework-bundle: ~2.3
- symfony/http-kernel: ~2.3
Requires (Dev)
- matthiasnoback/symfony-config-test: 0.*
- phpunit/phpunit: >=3.7
- satooshi/php-coveralls: dev-master
This package is auto-updated.
Last update: 2024-09-16 03:16:23 UTC
README
[] (https://travis-ci.org/egulias/TagDebugCommandBundle)
此包提供了一个简单的命令 container:tag-debug
,允许通过提供有关应用中定义的标签服务的信息来轻松调试标记的服务。它将检索有关所有标记服务的信息。
用法
对于任何命令,您应该使用:从您的项目根目录使用 app/console
。命令是
$ php app/console container:tag-debug
可用选项
--show-private
:如果指定,将显示私有服务。--filter
:可以有多个这样的选项。形式为--filter name=param1,param2
,其中param
是给定过滤器的参数。
可用过滤器
- 名称(
name
):按标签名称过滤,精确匹配。需要一个参数,例如:--filter name=tag_name
- 属性名称(
attribute_name
):按标签属性名称过滤,精确匹配。需要一个参数,例如:--filter attribute_name=attr_name
- 属性值(
attribute_value
):按标签属性值过滤,精确匹配。需要两个参数,例如:--filter attribute_value=attr_name,attr_value
- 名称正则表达式(
name_regex
):按标签名称过滤,提供一个正则表达式。不需要提供分隔符(内部使用~
)。需要一个参数,例如:--filter name_regex=regex
有关更多信息,请参阅 TagDebug 库
示例用法和输出
示例过滤器
$ php app/console sf container:tag-debug --filter name=kernel.event_listener
两个过滤器,一个具有多个值
$ php app/console container:tag-debug --filter name=kernel.event_listener --filter attribute_value=event,kernel.controller
安装和配置
获取包
将其添加到您的 composer.json
Symfony >= 2.3
{ "require": { "egulias/tag-debug-command-bundle": "~1.0" } }
使用 composer 下载新需求
$ php composer.phar update egulias/tag-debug-command-bundle
将 TagDebugCommandBundle 添加到您的应用程序内核
<?php // app/AppKernel.php public function registerBundles() { return array( // ... new Egulias\TagDebugCommandBundle\EguliasTagDebugCommandBundle(), // ... ); }
配置您自己的过滤器
要创建您自己的过滤器,请按照以下步骤操作
- 在您的过滤器类中实现
Egulias\TagDebug\Tag\Filter
接口。过滤器将通过构造函数接收您定义的尽可能多的参数,来自控制台。请参阅上面的示例。如果您想接收参数,请记住添加构造函数。 - 在您的配置文件中添加
egulias_tag_debug_command: filters: - {class: Fully\Qualified\Filter\Class\Name, name:"filter_console_name"}
- 享受吧!