kmaking/multi-auth
Composer 安装命令:
composer require kmaking/multi-auth
包简介
Multi Auth for Laravel 6 based on Hesto/multi-auth package
README 文档
README
php artisan multi-auth:install {guard} -fphp artisan multi-auth:install {guard} -f --domainphp artisan multi-auth:install {guard} {service} -f --lucid
What it does?
With one simple command you can setup multi auth for your Laravel 6 project. The package installs:
- Model
- Migration
- Controllers
- Notification
- Routes
- routes/web.php
- {guard}/login
- {guard}/register
- {guard}/logout
- password reset routes
- routes/{guard}.php
- {guard}/home
- routes/web.php
- Middleware
- Views
- Guard
- Provider
- Password Broker
- Settings
Usage
Step 1: Install Through Composer
composer require kmaking/multi-auth --dev
Step 2: Install Multi-Auth files in your project
php artisan multi-auth:install {singular_lowercase_name_of_guard} -f
// Examples
php artisan multi-auth:install admin -f
php artisan multi-auth:install employee -f
php artisan multi-auth:install customer -f
Notice:
If you don't provide -f flag, it will not work. It is a protection against accidental activation.
Alternative:
If you want to install Multi-Auth files in a subdomain you must pass the option --domain.
php artisan multi-auth:install admin -f --domain
php artisan multi-auth:install employee -f --domain
php artisan multi-auth:install customer -f --domain
To be able to use this feature properly, you should add a key to your .env file:
APP_DOMAIN=yourdomain.com
This will allow us to use it in the routes file, prefixing it with the domain feature from Laravel routing system.
Using it like so: ['domain' => '{guard}.' . env('APP_DOMAIN')].
Step 3: Migrate new model table
php artisan migrate
Step 4: Try it
Go to: http://url_to_your_project/guard/login
Example: http://project/admin/login
Options
If you don't want model and migration use --model flag.
php artisan multi-auth:install admin -f --model
If you don't want views use --views flag.
php artisan multi-auth:install admin -f --views
If you don't want routes in your routes/web.php file, use --routes flag.
php artisan multi-auth:install admin -f --routes
Note
If you want to adapt the redirect path once your guard is logged out, add and override the following method in
your {guard}Auth\LoginController:
/** * Get the path that we should redirect once logged out. * Adaptable to user needs. * * @return string */ public function logoutToPath() { return '/'; }
Files which are changed and added by this package
-
config/auth.php
- add guards, providers, passwords
-
app/Http/Providers/RouteServiceProvider.php
- register routes
-
app/Http/Kernel.php
- register middleware
-
app/Http/Middleware/
- middleware for each guard
-
app/Http/Controllers/{Guard}Auth/
- new controllers
-
app/{Guard}.php
- new Model
-
app/Notifications/{Guard}ResetPassword.php
- reset password notification
-
database/migrations/
- migration for new model
-
routes/web.php
- register routes
-
routes/{guard}.php
- routes file for given guard
-
resources/views/{guard}/
- views for given guard
Change Log
Note: Never install configurations with same guard again after installed new version of package. So if you already installed your admin guard, don't install it again after you update package to latest version.
Laravel 6.0 Support Added
Note
This package was originally from Hesto/multi-auth, we improved only routes, controller and view files.
kmaking/multi-auth 适用场景与选型建议
kmaking/multi-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.2k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2018 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「auth」 「laravel」 「multi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kmaking/multi-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kmaking/multi-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kmaking/multi-auth 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Multiauth package
Theme and asset management for laravel
This package provides Laravel bindings and a Eloquent/Model trait for pragmarx/recovery package.
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
This package provides a flexible way to add Role-based Permissions to Laravel 6.x
Email Toolkit Plugin for CakePHP
统计信息
- 总下载量: 1.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-17