Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php declare(strict_types=1);
- namespace MyApp\Container;
- use Doctrine\MongoDB\Connection;
- use Doctrine\ODM\MongoDB\Configuration;
- use Doctrine\ODM\MongoDB\DocumentManager;
- use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
- AnnotationDriver::registerAnnotationClasses();
- $connection = new Connection('mongodb://mongodb:27017/app'); // will not select `app` database
- $config = new Configuration();
- $config->setDefaultDB('app'); // i must set as configuraion
- $config->setProxyDir('/app/var/cache');
- $config->setProxyNamespace('Proxies');
- $config->setHydratorDir('/app/var/cache');
- $config->setHydratorNamespace('Hydrators');
- $config->setMetadataDriverImpl(AnnotationDriver::create('/app/app/src/Model'));
- $dm = DocumentManager::create($connection, $config);
Add Comment
Please, Sign In to add comment