i’m using ZF2 with ODM and MongoDB. When i try to perform very simple tasks like:
/** @ODM\Document(collection="Test") */
class Test
{
...
}
I receive the Error “need to login”. Well, i know why this is a problem an i can solve it by using:
/** @ODM\Document(db="mongoDB", collection="Test") */
class Test
{
...
}
Instead of using the db declaration the whole time in every class, is there a way to add config values from the .local/.global config file or can i just reconfigure the configure options?
Thank you very much.
Have a read through this useful tutorial about implementing Doctrine with ZF2. You should be placing global configuration options in Module.php and config/local.php. This array key in Module.php:
And these DB connection parameters in local.php:
This will allow you to avoid repetition in your DB entities, allowing you to use just the following Doctrine declarations for each of your classes: