Entity don't want to flush - Symfony 3.4 / Mongodb / Php

后端 未结 1 792
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-25 16:11

When I try to flush an entity that all work well but nothing fill my database but 0 errors... There is my controller:

/**
* @Security(\"is_anonymous() or is_aut         


        
1条回答
  •  深忆病人
    2021-01-25 16:25

    try to add repository file path in the document header like this:

    /**
    * @MongoDB\Document(repositoryClass="AppBundle\Repository\MessageUserRepository")
    */
    class MessageUser
    {}
    

    And add these lines to your config file:

    doctrine_mongodb:
        connections:
            default:
                server: "%database_host%"
                options:
                    username: "%database_user%"
                    password: '%database_password%'
                    db: "%database_name%"
                    authSource: "%database_name%"
    
    
        default_database: '%database_name%'
        document_managers:
            default:
                auto_mapping: true
    

    then you need to call the manager in the controller file:

    $dm = $this->get('doctrine_mongodb')->getManager();
    

    I hope that works for you :)

    0 讨论(0)
提交回复
热议问题