nimblephp / debugbar
NimblePHP 的 Debugbar
0.1.1
2024-05-19 20:33 UTC
Requires
- php: >=8.2
- maximebf/debugbar: 1.*
- nimblephp/framework: ^0.1.3
README
Debugbar 是一个模块,可以轻松地将 PHP Debugbar 集成到基于 NimblePHP 的项目中。
文档 可以在以下链接找到: https://nimblemvc.github.io/documentation/extension/debugbar/start/#
安装
composer require nimblephp/debugbar
使用
安装 Composer 后,我们创建或编辑 Middleware.php
文件,并在 afterBootstrap
方法中粘贴以下代码:
(new Debugbar())->init();
在模板中添加
echo \Nimblephp\debugbar\Debugbar::renderHead();
现在 debugbar 已经初始化,我们可以在 index.php
的末尾设置它。
echo \Nimblephp\debugbar\Debugbar::render();
包含控制器加载时间和错误返回的完整 Middleware.php
文件。
<?php class Middleware extends \Nimblephp\framework\Middleware { public function afterBootstrap() { (new Debugbar())->init(); } public function handleException(Throwable $exception) { \Nimblephp\debugbar\Debugbar::$debugBar['exceptions']->addException($exception); } public function beforeController(string $controllerName, string $action, array $params) { \Nimblephp\debugbar\Debugbar::$debugBar['time']->startMeasure('load-controller-' . $controllerName . $action, 'Load ' . str_replace('\src\Controller\\', '', $controllerName) . ' controller'); } public function afterController(string $controllerName, string $action, array $params) { \Nimblephp\debugbar\Debugbar::$debugBar['time']->stopMeasure('load-controller-' . $controllerName . $action); } }
合作
我们鼓励合作!如果你有建议、发现了错误或想帮助开发,请打开 issue 或发送 pull request。
帮助
有关任何问题或疑问,请通过 github 上的 discussions 标签提问,链接为: https://github.com/NimbleMVC/Migrations/discussions