sourceability/console-toolbar-bundle

此扩展包可以在控制台/终端中显示网络工具栏。

0.1.13 2023-01-03 10:31 UTC

This package is auto-updated.

Last update: 2024-08-28 17:39:35 UTC


README

在终端中渲染 symfony 分析器工具栏。

Screen Shot 2021-05-18 at 17 52 13

每个面板都链接到相应的网络分析器页面。请确保使用支持超链接的终端以利用此功能。

安装

使用 composer 安装此扩展包

$ composer require --dev sourceability/console-toolbar-bundle

通过更新 config/bundles.php 启用扩展包

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // ...
    FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['dev' => true, 'test' => true],
    Sourceability\ConsoleToolbarBundle\SourceabilityConsoleToolbarBundle::class => ['dev' => true, 'test' => true],
];

config/packages/{dev,test}/sourceability_console_toolbar.yaml 中配置扩展包

sourceability_console_toolbar:
    toolbar:
        hidden_panels:
            - config
            - form
            - validator
            - logger

如果您的应用程序不是暴露在 http://localhost 上,请确保您已经为您的环境配置了 路由请求上下文

默认情况下,分析器不一定在 test 环境中运行。您可以像这样启用它

--- a/config/packages/test/web_profiler.yaml
+++ b/config/packages/test/web_profiler.yaml
@@ -3,4 +3,4 @@ web_profiler:
     intercept_redirects: false

 framework:
-    profiler: { collect: false }
+    profiler: { enabled:true, collect: true, only_exceptions: false }

还可以在 config/routes/test/web_profiler.yaml 中添加网络分析器路由

web_profiler_wdt:
    resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
    prefix: /_wdt

web_profiler_profiler:
    resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
    prefix: /_profiler

Behat

当编写/调试 behat 场景时,此扩展包非常有用。

首先通过在您的 behat 配置中添加以下内容来启用 behat 扩展

default:
    extensions:
        FriendsOfBehat\SymfonyExtension: ~
        Sourceability\ConsoleToolbarBundle\Behat\SymfonyToolbarExtension: ~

这将在新检测到 symfony 分析器时显示控制台工具栏

Screen Shot 2021-05-18 at 17 52 13

PHPUnit

将以下内容添加到您的 phpunit.xml 配置中

    <extensions>
        <extension class="Sourceability\ConsoleToolbarBundle\PHPUnit\ConsoleToolbarExtension">
            <arguments>
                <boolean>false</boolean> <!-- always show, if false use: TOOLBAR=true phpunit ...-->
                <integer>4</integer> <!-- Indentation -->
            </arguments>
        </extension>
    </extensions>

Screen Shot 2021-05-18 at 17 46 52

控制台

bin/console 现在有一个新的全局选项 --toolbar

Screen Shot 2021-05-18 at 18 02 22

此功能需要 sourceability/instrumentation,并具有以下扩展包配置

sourceability_instrumentation:
    profilers:
        symfony:
            enabled: true
    listeners:
        command:
            enabled: true