vincent030298 vincent030298 - 1 month ago 12
PHP Question

How is the acces control not valid YAML

I have a question, i am following the doc of symfony and i am at the security part.

The first bit is going good but when i am at the acces control part i get stuck.

It says this:


The file "C:\xampp\htdocs\zelfstudie\framework-standard-edition\app/config\security.yml" does not contain valid YAML in C:\xampp\htdocs\zelfstudie\framework-standard-





This my
security.yml
:

# To get started with security, check out the documentation:
# http://symfony.com/doc/current/book/security.html

security:
# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
in_memory:
memory: ~

firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
default:
anonymous: ~
http_basic: ~

access_control:
# require ROLE_ADMIN for /admin*
- { path: ^/admin, roles: ROLE_ADMIN }

main:
anonymous: ~
# activate different ways to authenticate

# http_basic: ~
# http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate

# form_login: ~
# http://symfony.com/doc/current/cookbook/security/form_login_setup.html

Answer

Because you have:

access_control:
    - { ... }
    main:
        anonymous: ~

This is mixing YAML lists and dictionaries which is not allowed. I guess main is a firewall name so it should probably be:

security:
    ...
    access_control:
        - { path: ^/admin, roles: ROLE_ADMIN }

    firewalls:
        main:
            anonymous: ~