vasek-purchart / tracy-blue-screen-bundle
此套餐允许您在您的 Symfony 应用程序中将 Tracy 的调试屏幕与默认的剖析器结合使用。
Requires
- php: ~7.2
- symfony/config: ~4.0
- symfony/console: ~4.0
- symfony/dependency-injection: ~4.0
- symfony/http-kernel: ~4.0
- symfony/twig-bundle: ~4.0
- symfony/yaml: ~4.0
- tracy/tracy: ~2.4
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-12 08:51:10 UTC
README
此套餐允许您在您的 Symfony 应用程序中将 Tracy 的调试屏幕 与默认的剖析器结合使用。
为什么 Tracy 的调试屏幕比 Symfony 默认的异常屏幕更好
- 您可以浏览函数调用参数的所有值。
- 有关当前请求和环境的所有信息。
- 您可以查看包含在异常中的所有信息(例如,私有属性)。
- 可配置堆栈跟踪中的文件链接,可以直接在 IDE 中打开。
- 全屏布局提供更多空间显示信息。
- 查看交互式 示例屏幕。
然而,当出现错误时,Symfony 剖析器提供了大量关于应用程序的有用信息,因此最好同时使用它们
控制台集成
为了在 Symfony 控制台 使用时提供相同的舒适度,此套餐将渲染的 BlueScreen 保存到文件中,并显示一个链接。如果您进行配置,它将直接在您的浏览器中打开异常。
用法
如果您没有任何自定义的 kernel.exception
监听器,则此功能将默认工作。但是,如果您有,则必须确保它们不返回任何响应,因为这会阻止剖析器显示(这与默认的 Symfony 异常屏幕相同)。
如果您需要更改此监听器的默认位置(请参阅 bin/console debug:event-dispatcher
中的顺序),请使用配置选项 listener_priority
。
此套餐期望您正在使用通过 TwigBundle 渲染的默认 Symfony 剖析器屏幕,该屏幕必须已注册。
如果您的应用程序中未配置 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.root_dir%/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%' vasek_purchart.tracy_blue_screen.tracy.blue_screen: '@my_blue_screen'
安装
使用 Composer 安装包 vasek-purchart/tracy-blue-screen-bundle
composer require vasek-purchart/tracy-blue-screen-bundle
在您的应用程序中注册此套餐
// config/bundles.php return [ // ... VasekPurchart\TracyBlueScreenBundle\TracyBlueScreenBundle::class => ['all' => true], ];