Silex 中的 WebProfiler 不显示用户

WebProfiler in Silex doesn't show user

我已将 silex/web-profiler 集成到 Silex 应用程序中:

"require-dev": {
    "silex/web-profiler": "^2.0"
}

并使用表单身份验证配置示例防火墙:

// Security
$app['security.firewalls'] = array(
    'main' => array(
        'pattern' => '^/',
        'anonymous' => true,
        'form' => array('login_path' => '/login', 'check_path' => '/login_check'),
        'users' => array(
            'admin' => array('ROLE_ADMIN', 'yi9/lVd8UOFIJ6PAMFt8gu3/r5g0qeCJvoSlLCsvMTythye19F77a'),
        ),
    )
);
$app->register(new Silex\Provider\SecurityServiceProvider(), array());

// Profiler
if ($app['debug']) {
    $app->register(new Silex\Provider\ServiceControllerServiceProvider());
    $app->register(new Provider\WebProfilerServiceProvider(), array(
        'profiler.cache_dir' => __DIR__.'/../cache/profiler',
        'profiler.mount_prefix' => '/_profiler', // this is the default
    ));
}
$app->boot();

我可以使用示例 admin 帐户登录并在控制器中访问用户,但 WebProfiler 不显示用户选项卡:

是否需要额外配置?

似乎为了在 Web 调试工具栏中显示带有用户信息的安全面板,您需要 install also the security bundle (where the SecurityDataCollector class resides)。

所以你只需要执行:

composer require --dev symfony/security-bundle

这应该足够了。