Can anyone explain me how to implement MongoDB instead of MySQL into my Phalcon app?
I mean, which configuration should I use in my index.php
file, I know I need to set some collectionManager
in it, but in the Phalcon's docs it is not clearly explained, or at least I didn't get it...
I've created the model without problems, but when I run the code it throws me this:
PhalconException: Service 'collectionManager' wasn't found in the dependency injection container
and on the docs it throws me this big config stuff:
// Attach an anonymous function as a listener for "model" events
$eventsManager->attach('collection', function($event, $model) {
if (get_class($model) == 'Robots') {
if ($event->getType() == 'beforeSave') {
if ($model->name == 'Scooby Doo') {
echo "Scooby Doo isn't a robot!";
return false;
}
}
}
return true;
});
Can someone please explain me how to configure index.php
file properly? Maybe a good idea would be put some easy "steps" into the ODM doc page (eg.:"How to configure MongoDB in phalcon? Ok, first do this, later this and then this. Now, lets learn the ODM...").