定制 alaminfirdows/laravel-multi-auth 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alaminfirdows/laravel-multi-auth

Composer 安装命令:

composer require alaminfirdows/laravel-multi-auth

包简介

Multi Auth package for Laravel project.

README 文档

README

  • php artisan laravel-multi-auth:install {guard} -f
  • php artisan laravel-multi-auth:install {guard} -f --domain
  • php artisan laravel-multi-auth:install {guard} {service} -f --lucid

What it does?

This a simple package to create the multi authentication feature on your Laravel 6.* project. By running some simple command you can setup multi auth for your Laravel project. The package installs:

  • Model
  • Migration
  • Controllers
  • Notification
  • Routes
    • routes/web.php
      • {guard}/login
      • {guard}/register
      • {guard}/logout
      • Password Reset Routes
        • {guard}/password/reset
        • {guard}/password/email
    • routes/{guard}.php
      • {guard}/home
  • Middleware
  • Views
  • Guard
  • Provider
  • Password Broker
  • Settings

Usage

Step 1: Install Through Composer

composer require alaminfirdows/laravel-multi-auth

Step 2: Install Multi Auth in Your Project

php artisan laravel-multi-auth:install {singular_lowercase_name_of_guard} -f

// Examples
php artisan laravel-multi-auth:install admin -f
php artisan laravel-multi-auth:install employee -f
php artisan laravel-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 laravel-multi-auth:install admin -f --domain
php artisan laravel-multi-auth:install employee -f --domain
php artisan laravel-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://project_url/GuardName/login

Example: http://myproject.dev/customer/login

Options

If you don't want model and migration use --model flag.

php artisan laravel-multi-auth:install admin -f --model

If you don't want views use --views flag.

php artisan laravel-multi-auth:install admin -f --views

If you don't want routes in your routes/web.php file, use --routes flag.

php artisan laravel-multi-auth:install admin -f --routes

Note

If you want to change the redirect path for once your guard is logged out. Add and override the following method in your {GuardName}\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/Models/{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

Changelog

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.

v0.0.1-alpha

  • Updated all deprecated string helpers to Laravel 6.0
  • Reform Controllers Path and namespace
  • Reform Models Path and namespace

Special thanks to Piotr Łosiak (Hesto)

I inspired to create this package from hesto/multi-auth.

alaminfirdows/laravel-multi-auth 适用场景与选型建议

alaminfirdows/laravel-multi-auth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 753 次下载、GitHub Stars 达 10, 最近一次更新时间为 2019 年 10 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「multi-auth」 「laravel-multi-auth」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 alaminfirdows/laravel-multi-auth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 alaminfirdows/laravel-multi-auth 我们能提供哪些服务?
定制开发 / 二次开发

基于 alaminfirdows/laravel-multi-auth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 753
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-23