egulias / listeners-debug-command-bundle
Symfony 2 控制台命令用于调试监听器
3.0.0
2014-08-10 18:58 UTC
Requires
- egulias/listeners-debug: 1.0.*
- symfony/console: ~2.3
- symfony/dependency-injection: ~2.3
- symfony/framework-bundle: ~2.3
- symfony/http-kernel: ~2.3
Requires (Dev)
- phpunit/phpunit: >=3.7
- satooshi/php-coveralls: dev-master
README
此捆绑包提供了一个简单的命令 container:debug:listeners
,允许您通过提供有关应用程序中定义的监听器的有用信息来轻松调试监听器。它将检索所有带有 .event_listener 标记的监听器信息
重要
Symfony 2.2.X
如果您使用的是 Symfony <= 2.2,请更新您的 composer.json 文件以使用版本=1.4.1,这是 Symfony 2.2.x 的当前稳定分支
Symfony 2.0.X
如果您使用的是 Symfony 2.0.x,请更新您的 deps 文件以使用版本=symfony2.0.x,这是 Symfony 2.0.x 的当前稳定分支
使用方法
对于任何命令,您都应该使用:从项目根目录运行 app/console
。命令是:app/console container:debug:listeners
可用选项
有 4 个可用选项
- --show-private : 如果指定,将显示私有服务
- --event=event.name: 如果指定,将过滤以仅显示监听到给定名称的监听器(按优先级降序排列)
- --order-asc: 与 --event 结合使用时,将按优先级升序排序
- --listeners: 如果指定,将过滤以仅显示监听器(仅从 Symfony 2.1.x 开始可用)
- --subscribers: 如果指定,将过滤以仅显示订阅者(仅从 Symfony 2.1.x 开始可用)
示例输出(Symfony >= 2.3)
- 对于
container:debug:listeners
的输出 这里 - 对于
container:debug:listeners --event=kernel.response
的输出 这里 - 对于
container:debug:listeners listener.id
的输出 这里 - 对于
container:debug:listeners --listeners
的输出 这里 - 对于
container:debug:listeners --subscribers
的输出 这里
示例输出(Symfony >= 2.1.x <= 2.2.x)
- 对于
container:debug:listeners
的输出 这里 - 对于
container:debug:listeners --event=kernel.response
的输出 这里 - 对于
container:debug:listeners listener.id
的输出 这里 - 对于
container:debug:listeners --listeners
的输出 这里 - 对于
container:debug:listeners --subscribers
的输出 这里
示例输出(Symfony 2.0.x)
- 对于
container:debug:listeners
的输出 这里 - 对于
container:debug:listeners --event=kernel.request
的输出 这里 - 对于
container:debug:listeners listener.id
的输出 这里
安装和配置
获取捆绑包
添加到您的 composer.json
##Symfony >= 2.3
{
"require": {
"egulias/listeners-debug-command-bundle": "1.9.0"
}
}
##Symfony >= 2.2
{
"require": {
"egulias/listeners-debug-command-bundle": "symfony2.2"
}
}
使用 composer 下载新需求
$ php composer.phar update egulias/listeners-debug-command-bundle
将 ListenersDebugCommandBundle 添加到您的应用程序内核
<?php // app/AppKernel.php public function registerBundles() { return array( // ... new Egulias\ListenersDebugCommandBundle\EguliasListenersDebugCommandBundle(), // ... ); }
##Symfony 2.0.x 添加到您的 /deps
文件
[EguliasListenersDebugCommandBundle]
git=git@github.com:egulias/ListenersDebugCommandBundle.git
target=/bundles/Egulias/ListenersDebugCommandBundle
version=symfony2.0.x
然后运行 php bin/vendors install
。
注册命名空间
<?php // app/autoload.php $loader->registerNamespaces(array( 'Egulias' => __DIR__.'/../vendor/bundles', // your other namespaces ));
将 ListenersDebugCommandBundle 添加到您的应用程序内核
<?php // app/AppKernel.php public function registerBundles() { return array( // ... new Egulias\ListenersDebugCommandBundle\EguliasListenersDebugCommandBundle(), // ... ); }