wuifdesign/laravel-multiauth
最新稳定版本:v0.3.5
Composer 安装命令:
composer require wuifdesign/laravel-multiauth
包简介
MultiAuth integration for Laravel
关键字:
README 文档
README
Laravel: 5.0, 5.1
This Package extends the default Auth library to allow logging in with accounts from different database tables or even different databases. For example if you want to save your backend and a frontend users in a different table to keep them separated.
Works with the default Laravel 5 AuthController and PasswordController!
Installation
The easiest way is to run the following command:
composer require wuifdesign/laravel-multiauth
Otherwise you can include the package in your composer.json file,
"require": {
"wuifdesign/laravel-multiauth": "0.3.*"
}
and update or install via composer:
composer update
Now you have to open up your app/config/app.php and add
'providers' => [
...
WuifDesign\MultiAuth\ServiceProvider::class
]
Configuration is pretty easy too, take app/config/auth.php with its default values
return array(
'driver' => 'eloquent',
'model' => 'User',
'table' => 'users',
'password' => array(
'email' => 'emails.password',
'table' => 'password_reminders',
'expire' => 60,
),
);
and replace the first three options (driver, model, table) and replace them with the following
return array(
'default' => 'user',
'multi' => array(
'admin' => array(
'driver' => 'eloquent',
'model' => Admins::class,
),
'user' => array(
'driver' => 'eloquent',
'model' => Users::class,
'password' => [
'email' => 'users.emails.password',
]
)
),
'password' => array(
'email' => 'emails.password',
'table' => 'password_reminders',
'expire' => 60,
),
);
Usage
Everything is done by using routes. Just add a key "auth" to the route array with the value you used as a key in your app/config/auth.php
Route::get('/', array(
'uses' => function () {
return 'Hello World';
},
'middleware' => [ 'auth' ],
'auth' => 'admin',
));
Now if you call Auth::check() or any other function, it will use the driver and model set in the config for the key "admin".
If you don't add a "auth" to the route, the "default" type defined in the app/config/auth.php will be used.
If you want to check a specific auth while in a route using a different auth, you can use Auth::type($auth_key) to get the wanted auth manager.
Auth::type('admin')->check();
To get the current auth_key used by the route, or the default value, if you haven't set it in the route use.
Auth::currentType();
If you want to login as a different user, just use Auth::impersonate($id, $auth_key = null, $remember = false). If you
don't parse a auth_key, the key set via route, or the default one will be used.
Auth::impersonate(3, 'admin');
wuifdesign/laravel-multiauth 适用场景与选型建议
wuifdesign/laravel-multiauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 892 次下载、GitHub Stars 达 7, 最近一次更新时间为 2015 年 08 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「multiauth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wuifdesign/laravel-multiauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wuifdesign/laravel-multiauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wuifdesign/laravel-multiauth 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Multiauth package
Multiauth and custom grants for laravel passport
Laravel Multiauth package
Alfabank REST API integration
create laravel multi-auth guard setup files, middleware, models, migrations etc
Laravel passport multiple user authentication
统计信息
- 总下载量: 892
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-16