symflo / sy-mongodb-odm-plugin
symfony 1.x plugin for symflo/mongodb-odm.
Installs: 26
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony1-plugin
Requires
- composer/installers: *
- symflo/mongodb-odm: dev-master
- symflo/sy-dependency-injection-plugin: dev-master
This package is not auto-updated.
Last update: 2024-11-05 06:04:53 UTC
README
use MongoDB ODM for PHP for SF1.
Requirements
- PHP 5.4+
- SyDependencyInjectionPlugin
Installation
Add autoload Composer on your symfony project.
In the config/ProjectConfiguration.class.php
add:
<?php require_once __DIR__.'/../vendor/autoload.php'; ?>
Add Symfony DependencyInjection Component in your composer.json
"require": { ... "symflo/sy-mongodb-odm-plugin": "dev-master" ... },
Activate the plugin in the config/ProjectConfiguration.class.php
.
<?php class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins(array( /* ... */ 'syMongodbOdmPlugin', )); } } ?>
And activate extension to load services in your app.yml
syDependencyInjectionPlugin: extensions: - SyMongodbOdmExtension ...
Configuration
In app.yml
:
all: syMongodbOdmPlugin: databases: default: host: 127.0.0.1 user: '' password: '' database: database documents: user: class: 'MongoUserDocument' collectionName: 'users' collectionClass: 'MongoUserCollection' message: class: 'MongoMessageDocument' collectionName: 'messages'
In your Action
<?php //... public function executeYourAction(sfWebRequest $request) { $dm = $this->getService('symflo.mongodbodm.document.manager'); $users = $dm->getCollection('users')->find(); } //... ?>
Ensure Index Task
Prepare document indexes like MongoDB ODM for PHP. Then run task:
php symfony sy:syMongodbOdmEnsureIndex