1. Go to this page and download the library: Download cimrie/odm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
cimrie / odm example snippets
use App\Http\Controllers\Controller;
use Doctrine\ODM\MongoDB\DocumentManager;
class IndexController extends Controller {
public function index(DocumentManager $documentManager) {
// code as normal ...
$documentManager->flush();
// etc.
}
}
use CImrie\ODM\DocumentManagerFactory;
use CImrie\ODM\Configuration\OdmConfigurationFactory;
use CImrie\ODM\Configuration\Connections\ConnectionResolver;
use CImrie\ODM\Configuration\MetaData\MetaDataRegistry;
use \CImrie\ODM\Common\Registries\ListenerRegistry;
use CImrie\ODM\Configuration\MetaData\Annotations;
$connectionFactories = [
new \CImrie\ODM\Configuration\Connections\MongodbConnectionFactory()
];
$config = [
'mongodb' => [
'driver' => 'mongodb',
'host' => 'localhost',
'port' => 27017,
'database' => 'odm',
'username' => 'secretuser',
'password' => 'secretpass',
'options' => [
'database' => 'admin',
],
]
];
$metaDataDrivers = [
new Annotations()
];
$dmFactory = new DocumentManagerFactory(
new OdmConfigurationFactory(),
new ConnectionResolver($connectionFactories, $config),
new MetaDataRegistry([Annotations::class]),
null, //cache manager
new ListenerRegistry(),
null //logger, which can be created by extending CImrie\ODM\Logging\Logger
);
/*
* <!------------- WARNING -------------!>
*/
//TODO - THIS PART OF THE DOCS IS NOT COMPLETE
$dmFactory->create(new \CImrie\ODM\Common\Config(
[
],
[
],
[
'database' => [
'connections' => [
]
]
]
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.