Guest User

Untitled

a guest
Oct 16th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. <?php declare(strict_types=1);
  2.  
  3. namespace MyApp\Container;
  4.  
  5. use Doctrine\MongoDB\Connection;
  6. use Doctrine\ODM\MongoDB\Configuration;
  7. use Doctrine\ODM\MongoDB\DocumentManager;
  8. use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
  9.  
  10. AnnotationDriver::registerAnnotationClasses();
  11. $connection = new Connection('mongodb://mongodb:27017/app'); // will not select `app` database
  12. $config = new Configuration();
  13. $config->setDefaultDB('app'); // i must set as configuraion
  14. $config->setProxyDir('/app/var/cache');
  15. $config->setProxyNamespace('Proxies');
  16. $config->setHydratorDir('/app/var/cache');
  17. $config->setHydratorNamespace('Hydrators');
  18. $config->setMetadataDriverImpl(AnnotationDriver::create('/app/app/src/Model'));
  19. $dm = DocumentManager::create($connection, $config);
Add Comment
Please, Sign In to add comment