我试图在我的Symfony Project上安装SonataAdmin,但在文档第二部分的末尾,当我试图继续“http://localhost:8000/admin/”我有一个错误:“您已经申请了一个非-existent服务“admin.category”中(其正在从“C:\ wamp64 \ WWW \奏/应用/配置\ routing.yml中”输入)。确保有支持“sonata_admin”型装载机“。SonataAdmin安装问题
我不知道为什么,我给我给我所有的参数的代码也许它可以帮助你理解我的问题。
参数: #parameter_name:值
服务:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
admin.category:
class: AppBundle\Admin\CategoryAdmin
arguments: [~, AppBundle\Entity\Category, ~]
tags:
- { name: sonata.admin, manager_type: orm, label: Category }
# makes classes in src/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
AppBundle\:
resource: '../../src/AppBundle/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
exclude: '../../src/AppBundle/{Entity,Repository,Tests}'
# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
AppBundle\Controller\:
resource: '../../src/AppBundle/Controller'
public: true
tags: ['controller.service_arguments']
# add more services, or override services that need manual wiring
# AppBundle\Service\ExampleService:
# arguments:
# $someArgument: 'some_value'
`
压痕是怎么了?我加你这个文件的照片。 Service code
在我的routing.yml只有: '应用: 资源: '@的appbundle /控制器/' 类型:注释 admin_area: 资源: “@ SonataAdminBundle /资源/配置/路由/ sonata_admin.xml” 前缀:/管理 _sonata_admin: 资源。 类型:sonata_admin 前缀:/ admin ' – jpp28
好吧我误解了哪个文件与上面的代码块相匹配,它是services.yml(在app/config中)对不对?所以你应该削减你的'category.admin'块并将其粘贴到我提到的文件中,这就是你必须声明管理类的地方 – KelgMak
是的,它是app/config/service.yml文件。但是我的项目实际上是空的。我只有奏鸣曲,我只是想在真正的项目中使用它之前在空的项目中测试它。我将尽力在一个真实的项目上做到这一点,我们将会看到 – jpp28