Nepal12
Nepal12

Reputation: 593

Symfony2 : InvalidTypeException in ArrayNode.php line 267:

Its really bothering me a lot. Where did I make mistake or How can I solve this error.

I got an error as InvalidTypeException in ArrayNode.php line 267: -- Invalid type for path "security.providers.in_memory.memory.users.admin:{ password". Expected array, but got string

I am implementing the controller from symfony cookbook. Here is my security.yml

security:
encoders:
    Symfony\Component\Security\Core\User\User: plaintext
    Leo\CLUBBundle\Entity\User: bcrypt
role_hierarchy:
    ROLE_ADMIN: [ROLE_USER]
providers:
    chain_provider:
        chain:
            providers: [in_memory, user_db]
    in_memory:
        memory:
            users:
                admin:{ password: adminpass, roles:ROLE_ADMIN}
    user_db:
        entity:{ class: LeoCLUBBundle:User, property:username }
firewalls:
    main:
        pattern: /.*
        form_login:
            login_path: /login_path
            check_path: /login_check
            default_target_path: /
        logout:
            path: /logout
            target: /
        security: true
        anonymous: true
access_control:
    - { path: /login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: /user, roles: ROLE_ADMIN }
    - { path: /.*, roles: IS_AUTHENTICATED_ANONYMOUSLY }

Upvotes: 1

Views: 2820

Answers (2)

Cbuz
Cbuz

Reputation: 11

I had the same problem after manual modification of composer.json and composer.lock files.

After that modifications, trying to install mailer with "composer require symfony/mailer", I had many errors under "Your requirements could not be resolved to an installable set of packages.":

Problem 1 - Root composer.json requires symfony/asset 6.0.*, found symfony/asset[v6.0.0, v6.0.1] but the package is fixed to v4.4.27 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Problem 2 - Root composer.json requires symfony/console 6.0.*, found symfony/console[v6.0.0, v6.0.1, v6.0.2] but the package is fixed to v4.4.36 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Problem 3 .....and so on"

To fix this problems I had to futher modify composer.json and composer.lock, until the "composer update "symfony/*" -W" worked fine, except for the message "Unrecognized option "anonymous" under "security.firewalls.main".

I found out that the security.yaml file got changed: instead of "lazy: true" there was "anonymous: lazy".

Reverting to "lazy: true", no more error messages.

Upvotes: 0

Ziumin
Ziumin

Reputation: 4860

Spaces and intentions are very important in Yaml, so change

admin:{ password: adminpass, roles:ROLE_ADMIN}

to

admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

Also change

entity:{ class: LeoCLUBBundle:User, property:username }

to

entity: { class: LeoCLUBBundle:User, property: username }

Upvotes: 4

Related Questions