limoncello-php / app

Quick start JSON API application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does limoncello support NoSQL, like mongoDB?

dreamsbond opened this issue · comments

Curious if limoncello supports mongoDB.

Limoncello uses DBAL to work with databases. A list of supported databases by DBAL is here. Thus, if you have MongoDB installed you can either use it directly or with a wrapper such as Doctrine MongoDB.

Technically, it would be better to place either of them to the application container as shown here and use it anywhere in the app.

For example,

class MongoDbConfigurator implements ContainerConfiguratorInterface
{
    public static function configureContainer(LimoncelloContainerInterface $container): void
    {
        $container[\MongoDB\Driver\Manager::class] = function (PsrContainerInterface $container) {
            // read MongoDB settings (e.g. connect string and etc)
            $settings = $container->get(SettingsProviderInterface::class)->get(\Settings\MongoDB::class);
            
            // create MongoDB connection with settings
            return new \MongoDB\Driver\Manager(...);
        };
    }
}

Thanks!