Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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 }

Spaces and intentions are very important in Yaml, so change

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

Also change

entity:{ class: LeoCLUBBundle:User, property:username }
entity: { class: LeoCLUBBundle:User, property: username }
                Using this will then trigger another error Unrecognized options "entity:{ class" under "security.providers.user_db"
– Nepal12
                Dec 29, 2014 at 18:21
                I haven't realized that a single space will give me such a big trouble. Thanks a lot. Learnt my lesson.
– Nepal12
                Dec 29, 2014 at 18:37

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.