reshadman/laravel-mongo-auth
最新稳定版本:1.0.0
Composer 安装命令:
composer require reshadman/laravel-mongo-auth
包简介
A native mongo db auth driver on Laravel 5's default auth module.
README 文档
README
This package does not require any external MongoDB related dependencies except the Php MongoDB Driver and simply uses Auth::extend() to extend the native Laravel Auth module.
Installation
- Run
composer require reshadman/laravel-mongo-authin your project's composer root. - Add the
Reshadman\LmAuth\LmAuthServiceProviderservice provider to your app. - Run
php artisan vendor:publishcommand to generate package config files. - In
auth.phpconfig set thedrivertolmauth:
<?php return [ //... 'driver' => 'lmauth' ];
Approach
An instance of MongoCollection is passed to \Reshadman\LmAuth\MongoDbUserProvider like below :
From \Reshadman\LmAuth\LmAuthServiceProvider :
<?php $this->app['auth']->extend('lmauth', function(Application $app){ $config = $app['config']->get('lmauth'); return new MongoDbUserProvider( $app['lmauth.collection'], // Should be bound to an instance of \MongoCollection $app['hash'], $config ); });
The above code needs $app['lmauth.collection'] to be available in IoC container which is an instance of MongoCollection.
If you set the use_default_collection_provider config option to true, the package will create a new binding for that.
You may also create your own driver with another driver name and pass your own config and mongo collection instance to it.
<?php Auth::extend('my-lmauth', function($app) { $config = $app['config']->get('lmauth'); // or your desired $mongoCollection = $app['global_mongo_connection']->myDb->myCollection; return new \Reshadman\LmAuth\MongoDbUserProvider($mongoCollection, $app['hash'], $config); });
The default_connection_closure config
If you pass a closure to this config key then the package will use this closure to get the MongoClient connection to connect to mongodb. Usefull when using Doctrine Mongo db package or alternatives.
<?php return [ //... 'default_connection_closure' => function($app) { return new \MongoClient('192.168.0.2:27013'); // or $app['mongo.singleton_connection'] } ];
If you set the above option to null the the package will use a singleton shared instance ( new \MongoClient()) which has lmauth.connection key in the container.
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 29
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-02-27