blackmesasl / silex-chromephp
Silex 包用于将 ChromePHP 实现为 ServiceProvider
Requires
- php: >=5.3.0
- ccampbell/chromephp: dev-master
Requires (Dev)
- silex/silex: *
This package is not auto-updated.
Last update: 2024-09-28 15:19:17 UTC
README
#SilexChromePhp
SilexChromePhp 是围绕 ccampbell/chromephp (https://github.com/ccampbell/chromephp) 库的包装,允许使用 Chrome Logger Google Chrome 扩展程序来调试 PHP 应用程序。
ChromePhpServiceProvider 可以轻松地将 ChromePhp 集成到 Silex 微框架 (http://silex.sensiolabs.org)
##安装
###SilexChromePhp 和 ChromePhp
将 blackmesasl/silex-chromephp 添加到您的依赖项中。
通过命令行
php composer.phar require "blackmesasl/silex-chromephp":"dev-master"
或添加以下行到您的 composer.json 文件
"blackmesasl/silex-chromephp": "dev-master"
并运行 php composer.phar update
###Chrome Logger 扩展程序
要能够看到您从服务器端代码发送的调试消息,您需要从 Chrome Web Store 安装 Chrome Logger 扩展程序。
一旦您在 Silex 项目上有了服务提供者,并在 Chrome 浏览器上安装了扩展程序,只需启用扩展程序即可在开发者工具的 控制台 面板上开始获取调试信息。
有关更多信息,请参阅 Chrome Logger 网站。
##使用
导入命名空间并在您的 Silex 应用程序上注册 ServiceProvider
use Blackmesa\SilexChromePhp\Provider\ChromePhpServiceProvider; $app->register(new ChromePhpServiceProvider());
现在您可以通过 $app['chromephp'] 对象访问并调用其方法。
###可用方法
infowarnerrorlogtablegroupgroupCollapsedgroupEnd
$app->get('/myroute', function() use ($app) { try { $app['chromephp']->info('Let\'s render the view!'); return $app['twig']->render('mytemplate.html.twig'); } catch(Exception $e) { $app['chromephp']->error($e); throw $e; } $app['chromephp']->warn('This is impossible!!!'); });
ChromePhpServiceProvder 使用 $app['debug'] 标志来决定是否将信息发送到浏览器。
##另请参阅