我正在尝试使用FOSUserBundle配置Symfony3,一步一步跟随Symfony [FOSUserBundle Docs] [1],但最后我收到此错误:
ParameterNotFoundException in RegisterMappingsPass.php line 237:
You have requested a non-existent parameter "Could not determine the Doctrine manager. Either Doctrine is not configured or a bundle is misconfigured.".
in RegisterMappingsPass.php line 237
at RegisterMappingsPass->getManagerName(object(ContainerBuilder)) in RegisterMappingsPass.php line 183
at RegisterMappingsPass->getChainDriverServiceName(object(ContainerBuilder)) in RegisterMappingsPass.php line 151
at RegisterMappingsPass->process(object(ContainerBuilder)) in Compiler.php line 104
at Compiler->compile(object(ContainerBuilder)) in ContainerBuilder.php line 545
at ContainerBuilder->compile() in Kernel.php line 477
at Kernel->initializeContainer() in Kernel.php line 117
at Kernel->boot() in Kernel.php line 166
at Kernel->handle(object(Request)) in app_dev.php line 30
at require('~/Dev/test-api/web/app_dev.php') in router_dev.php line 40
我检查了我的供应商目录,并且学说存在。
我的security.yml:
# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html
security:
encoders:
FOS\UserBundle\Model\UserInterface: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_token_generator: security.csrf.token_manager
# if you are using Symfony < 2.8, use the following config instead:
# csrf_provider: form.csrf_provider
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
config.yml:
进口: - {resource:parameters.yml} - {resource:security.yml} - {resource:“@ CambioBundle / Resources / config / services.xml”}
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
# translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
default_connection: db_query
connections:
db_query:
driver: %database_driver%
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
# orm:
# auto_generate_proxy_classes: "%kernel.debug%"
# naming_strategy: doctrine.orm.naming_strategy.underscore
# auto_mapping: true
##FOSUserBundle Configuration
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: main
user_class: Cambio\CambioBundle\Entity\User
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
真的不知道这里有什么问题。
更新
composer.jason:
"friendsofsymfony/user-bundle": "~2.0@dev"
[1]: http://symfony.com/doc/current/bundles/FOSUserBundle/index.html
答案 0 :(得分:1)
此错误与您的FOSUserBundle无关,它与错误的学说配置有关。你应该在config.yml
中取消注释orm部分的doctrine设置orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true