Getting a registrar working in Doctrine MongoDB ODM?

I am trying to get the logger to work in ODM Doctrine.

// .. some initialization code here ... $mongoConfig->setLoggerCallable(function(array $log){ print_r($log); die("Mongo Logging Called..."); }); $dm = \Doctrine\ODM\MongoDB\DocumentManager::create(new \Doctrine\MongoDB\Connection(), $mongoConfig); 

Here's the link: http://www.doctrine-project.org/docs/mongodb_odm/1.0/en/reference/logging.html

I request documents using the document manager query builder. I have to successfully find and save documents. But a log call is not possible. What can i do wrong?

+6
source share
1 answer

Found a solution through the #doctrine IRC channel. The connection must be transmitted separately, because the DocumentManager does not apply the configuration passed to it to the connection that it creates. This will be fixed in a future version. This is how you do it -

 // setup the mongodb connection $connection = new \Doctrine\MongoDB\Connection(null, array(), $mongoConfig); // create the document manager for the connection above $dm = \Doctrine\ODM\MongoDB\DocumentManager::create($connection, $mongoConfig); 
+6
source

Source: https://habr.com/ru/post/892049/


All Articles