![](/img/trans.png)
[英]Symfony2 FOSUserBundle - You have requested a non-existent service “security.user_checker”
[英]Sonata Admin: non-existent service "security.authorization_checker"
我正在嘗試使用 Sonata Admin Bundle 設置一個簡單的 CMS。 I use composer to add sonata-project/admin-bundle
and sonata-project/doctrine-orm-admin-bundle
to an empty git repository, then follow the rest of the directions on https://sonata-project.org/bundles/ admin/3-x/doc/getting_started/installation.html
現在我訪問http://localhost/admin/dashboard
,說明應該給我一個空白儀表板。 相反,我得到一個 ServiceNotFoundException,說明:
服務“sonata.admin.menu.group_provider”依賴於不存在的服務“security.authorization_checker”。
是否有我需要安裝/添加的捆綁包或配置才能解決此問題?
===
當我運行bin/console debug:container security.authorization_checker
時,我得到以下 output:
在 CheckExceptionOnInvalidReferenceBehaviorPass.php 第 86 行:
服務“sonata.admin.menu.group_provider”依賴於不存在的服務“security.authorization_checker”。
===
這是 config/packages/sonata_admin.yaml:
sonata_block:
blocks:
# enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
...這里是 config/services.yaml:
parameters:
locale: 'en'
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
# makes classes in src/ available to be used as services
# this creates a service per class whose id is the fully-qualified class name
App\:
resource: '../src/*'
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
...這是我的捆綁包。php:
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Sonata\BlockBundle\SonataBlockBundle::class => ['all' => true],
Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true],
Sonata\AdminBundle\SonataAdminBundle::class => ['all' => true],
Sonata\Doctrine\Bridge\Symfony\SonataDoctrineBundle::class => ['all' => true],
Sonata\Form\Bridge\Symfony\SonataFormBundle::class => ['all' => true],
Sonata\Twig\Bridge\Symfony\SonataTwigBundle::class => ['all' => true],
];
您需要安裝 symfony 安全。 如果你還沒有它,也許可以彎曲。
composer require symfony/flex
composer require security
這將自動為您安裝和配置捆綁包。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.