ulff / php-mongodb-client-bundle
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.5
- mongodb/mongodb: ~1.1
- symfony/framework-bundle: ~2.1|~3.0
This package is not auto-updated.
Last update: 2025-01-19 06:39:33 UTC
README
A Symfony bundle for MongoDB. Compatible with new mongodb driver, unlike the doctrine/mongodb which is compatible only with deprecated and no longer supported mongo driver.
See: https://docs.mongodb.com/ecosystem/drivers/php/#compatibility
Installation and configuration
Step 1: Install bundle
Install bundle using composer:
php composer.phar require "ulff/php-mongodb-client-bundle:dev-master"
Enable the bundle in AppKernel.php:
// app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Ulff\PhpMongodbClientBundle\UlffPhpMongodbClientBundle(), ]; // ... }
Step 2: add bundle configuration
Add configuration to config.yml. Minimal required is:
# app/config/config.yml ulff_php_mongodb_client: connection: host: hostname-here
There are also other configuration options, like:
# app/config/config.yml ulff_php_mongodb_client: connection: host: hostname-here port: 27017 # optional, default 27017 username: username-here # optional, default not set password: password-here # optional, default not set options: { } # any custom connection options here, passed as assoc array
Replace values with proper ones.
Usage
Client usage
Mongodb client is available as a service:
$client = $this->get('ulff_php_mongodb_client.client');
Getting manager
Service provides access to the mongodb manager:
$manager = $this->get('ulff_php_mongodb_client.client')->getManger();