I completed all steps in this manual. But when I try to execute:
bin/console doctrine:schema:update --force
I get this exception:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized options "0, 1, 2, 3" under "security.firewalls.access_control"
How does your security configuration look like?
This is my 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_CUSTOMER: ROLE_USER
#ROLE_MERCHANT: ROLE_USER
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
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 }
The access_control option must not be under the firewalls key but directly in security.
Thank you so worked, but now such an exception:
[Symfony\Component\Config\Definition\Exception\ForbiddenOverwriteException]
Configuration path "fos_user.db_driver" cannot be overwritten. You have to define all options for this path, and any of its sub-paths in one configuration section.
It fos_user section in my config.yml:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
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
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: KernelBundle\Entity\User
It looks like you define other FOSUserBundle config settings in other files (for example, in config_dev.yml, config_prod.yml etc.).
Thank you, yes, that was. It has been successfully installed. You have a very lively community, even at the weekend! Thank you for your work.
Most helpful comment
The
access_controloption must not be under thefirewallskey but directly insecurity.