Package Data | |
---|---|
Maintainer Username: | Cosmicist |
Maintainer Contact: | luciano.longo@gmail.com (Luciano Longo) |
Package Create Date: | 2013-01-15 |
Package Last Update: | 2013-04-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-17 03:05:16 |
Package Statistics | |
---|---|
Total Downloads: | 37 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
MongoDB library and Auth driver for Laravel 4.
It extends PHP's MongoDB Native Driver.
Require flatline/mongol
in your project's composer.json
:
{
"require": {
"flatline/mongol": "0.1.*"
}
}
Update or install your packages with composer update
or composer install
respectively.
Now you need to register MongolServiceProvider with Laravel.
Open up app/config/app.php
and add the following to the providers
key:
'Flatline\Mongol\MongolServiceProvider'
You can also register the facade in the class aliases, look for the aliases
key and add the following:
'Mongol' => 'Flatline\Mongol\Mongol'
This way you can use Mongol::connection()
instead of Flatline\Mongol\Mongol::connection()
.
In order to use your own database credentials you can extend the package configuration by
creating app/config/packages/flatline/mongol/config.php
.
You can do this by running the following Artisan command.
$ php artisan config:publish flatline/mongol
Here's an example configuration using mongohq
'default' => array(
'host' => 'alex.mongohq.com',
'port' => 10002,
'username' => 'your_username',
'password' => 'your_db_password',
'database' => 'your_db_name',
),
You can also connect as admin
'other_credentials' => array(
'host' => 'localhost',
'username' => 'your_admin_username',
'password' => 'your_admin_db_password',
'database' => 'your_db_name',
'admin' => true,
),
You can create as many database credential groups as you need.
To use Mongol with the Auth library, just set 'mongol' as the driver in app/config/auth.php
:
'driver' => 'mongol'
You use it the same way you would use the native driver, but first you need to get the connection and database.
To get your default connection use:
Mongol::connection();
To get other connection:
Mongol::connection('group');
To get the database just use:
Mongol::connection()->getDB();
And to get other db using the same credentials (you must be authenticated as admin), you can use:
Mongol::connection()->getDB('other_db_name')