cdn77 / tracy-blue-screen-bundle
此组件允许您在 Symfony 应用程序中将 Tracy 的调试界面与默认的剖析器结合使用。
Requires
- php: ^8.2
- symfony/config: ^6.4 || ^7.0
- symfony/console: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/yaml: ^6.4 || ^7.0
- tracy/tracy: ^2.8
Requires (Dev)
- cdn77/coding-standard: ^7.0
- matthiasnoback/symfony-dependency-injection-test: ^5.0
- mikey179/vfsstream: ^1.6.11
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.0
- phpunit/phpunit: ^10.0
- psalm/plugin-phpunit: 0.18.4
- vimeo/psalm: ^5.0.0
This package is auto-updated.
Last update: 2024-09-08 10:07:43 UTC
README
此组件允许您在 Symfony 应用程序中将 Tracy 的调试界面 与默认的剖析器结合使用。
为什么 Tracy 的调试界面比 Symfony 默认的异常界面更好
- 您可以浏览函数调用参数的所有值。
- 有关当前请求和环境的所有信息。
- 您可以查看包含在异常中的所有信息(例如,私有属性)。
- 可配置的堆栈跟踪文件链接,可以直接在 IDE 中打开。
- 全屏布局,提供更多空间显示信息。
- 查看交互式 示例界面。
然而,当出现错误时,Symfony 剖析器提供了大量有关应用程序的有用信息,因此最好两者都可用
控制台集成
为了在使用 Symfony 控制台 时提供相同的便利,此组件会将渲染的 BlueScreen 保存到文件,并显示链接。如果您进行了配置,它将在浏览器中直接打开异常。
使用方法
如果您没有任何自定义的 kernel.exception
监听器,则此功能将直接工作。但是,如果您有,您必须确保它们不返回任何响应,因为这会阻止剖析器显示(同样适用于默认的 Symfony 异常界面)。
如果您需要更改此监听器的默认位置(请参阅 bin/console debug:event-dispatcher
中的顺序),请使用配置选项 listener_priority
。
如果您的控制台没有 console.error
监听器来阻止此执行的执行,则控制台集成将直接工作。同样,您可以使用相应的 listener_priority
选项进行调整。
将 browser
选项配置为在浏览器中直接打开异常,配置的二进制文件必须可执行,使用 exec()
。
如果您想将应用程序配置为始终将警告和通知转换为异常,请使用 debug.error_handler.throw_at
参数(请参阅 PHP 手册 了解其他可用值)
parameters: debug.error_handler.throw_at: -1
此组件不提供专门的日志记录功能。如果您想在生产环境中使用 Tracy 进行日志记录,请使用 monolog-tracy-bundle,它提供 Tracy Monolog 处理程序。
配置
带有列出默认值的配置结构
# config/packages/tracy_blue_screen.yaml tracy_blue_screen: controller: # Enable debug screen for controllers. # Enabled by default only in dev environment with debug mode on. enabled: ~ # Priority with which the listener will be registered. listener_priority: 0 console: # Enable debug screen for console. # Enabled by default only in dev environment with debug mode on. enabled: ~ # Directory, where BlueScreens for console will be stored. # If you are already using Tracy for logging, set this to the same. # This will be only used, if given Tracy\Logger instance does not have a directory set. log_directory: '%kernel.logs_dir%' # Configure this to open generated BlueScreen in your browser. # Configuration option may be for example 'google-chrome' # or 'firefox'and it will be invoked as a shell command. browser: null # Priority with which the listener will be registered. listener_priority: 0 blue_screen: # Add paths which should be collapsed (for external/compiled code) so that actual error is expanded. collapse_paths: # Defaults: - '%kernel.project%/bootstrap.php.cache' - '%kernel.cache_dir%' # plus paths set in BlueScreen instance used (/vendor)
您还可以覆盖内部使用的服务,例如,如果您需要指定 BlueScreen 实例的选项,您可以使用 别名 提供自定义实例
services: my_blue_screen: class: 'Tracy\BlueScreen' properties: info: - 'environment: %kernel.environment%' cdn77.tracy_blue_screen.tracy.blue_screen: '@my_blue_screen'
安装
使用 Composer 安装包 cdn77/tracy-blue-screen-bundle
composer require cdn77/tracy-blue-screen-bundle
在您的应用程序中注册组件
// config/bundles.php return [ // ... Cdn77\TracyBlueScreenBundle\TracyBlueScreenBundle::class => ['all' => true], ];