triquang/laravel-auth-scaffold
Composer 安装命令:
composer require triquang/laravel-auth-scaffold
包简介
Scaffold API & Web authentication for any Eloquent model with multi-auth support — monolith or modular Laravel.
关键字:
README 文档
README
🚀 Quickly scaffold full Laravel authentication for any Eloquent model, supporting multi-auth in both API and Web UI — for monolith or modular apps.
This package accelerates authentication setup for custom models like Admin, Client, Vendor, etc., and works seamlessly with both standard Laravel and modular Laravel architectures (e.g., nwidart/laravel-modules).
✨ Features
- ✅ Supports any Eloquent model (
User,Admin,Client, etc.) - ✅ Scaffold for both API routes/controllers/services and Web (views/forms)
- ✅ Works with modules — fully compatible with
nwidart/laravel-modules - ✅ Multi-auth ready — configure multiple guards & providers automatically
- ✅ Generates:
- Auth-ready Model (or updates existing one)
- Migrations (with OTP, password reset)
- Auth controllers (API + optional Web)
- Requests, Services, Routes, Views (if
--web) - Auth config updates (
guards,providers,passwords)
- ✅ One single command does it all
API functions
- Register
- Login
- Logout
- Forgot Password
- Reset Password
- Verify OTP
WEB functions
- Includes all API functions above, plus:
- Show register view
- Show login view
- Show Forgot Password view
- Show Reset Password view
- Show Verify OTP view
📦 Installation
composer require triquang/laravel-auth-scaffold --dev
Optional: Publish Stubs
php artisan vendor:publish --provider="TriQuang\\LaravelAuthScaffold\\LaravelAuthScaffoldServiceProvider" --tag=auth-scaffold-stubs
This will publish stubs to:
/stubs/vendor/triquang/laravel-auth-scaffold/
🚀 Usage
php artisan make:auth-scaffold --model=Admin
Options
| Option | Description |
|---|---|
--model |
(Required) Name of the model to generate authentication for. Defaults to User. |
--module |
(Optional) Generate files inside Modules/{ModuleName}. |
--web |
(Optional) Include web views and web routes. |
Examples
1. Generate basic API auth for default User model
php artisan make:auth-scaffold
2. Generate API auth for Admin model
php artisan make:auth-scaffold --model=Admin
3. Generate full auth for Author model inside a module
php artisan make:auth-scaffold --model=Author --module=Blog
4. Generate web+API auth for Client model
php artisan make:auth-scaffold --model=Client --web
📂 File Structure Generated
Example with --model=Admin:
app/
├── Http/
│ ├── Controllers/
│ │ └── Auth/
│ │ ├── AdminApiAuthController.php
│ │ └── AdminWebAuthController.php # If --web
│ └── Requests
│ └── Auth
│ ├── AdminForgotPasswordRequest.php
│ ├── AdminLoginRequest.php
│ ├── AdminRegisterRequest.php
│ └── AdminResetPasswordRequest.php
├── Models/
│ └── Admin.php
└── Services/
└── Auth/
└── AdminAuthService.php
database/
└── migrations/
├── create_admins_table.php
├── create_admin_password_reset_tokens_table.php
└── create_admin_otp_codes_table.php
routes/
├── api.php # Updated
└── web.php # If --web
resources/
└── views/
└── auth/
├── admin-login.blade.php
├── admin-register.blade.php
├── admin-forgot-password.blade.php
├── admin-reset-password.blade.php
└── admin-verify-otp.blade.php
config/
└── auth.php # Auto-updated for guards/providers/passwords
🛡 Authentication Compatibility Check
- The command will:
- Check if model extends
Illuminate\Foundation\Auth\User - Check if model has required traits like
HasApiTokens - Insert guidance comments if not
- Check if model extends
🧩 Customization
You can customize the stub files to suit your coding standards:
php artisan vendor:publish --tag=auth-scaffold-stubs
Edit stubs in:
stubs/vendor/triquang/laravel-auth-scaffold/
🧭 Auto-Generated Code Markers
This package adds clear flags in generated code to help developers easily find and review them.
Example
// AUTO-GEN: Placeholder public function up() { Schema::create('admins', function (Blueprint $table) { $table->id(); $table->string('name'); $table->timestamps(); // AUTH-SCAFFOLD-MISSING-COLUMNS // Required authentication fields missing in 'admins' migration: // $table->string('email')->unique(); // $table->string('password'); // $table->string('otp')->nullable(); // $table->timestamp('email_verified_at')->nullable(); // $table->string('remember_token')->nullable(); // AUTH-SCAFFOLD-MISSING-COLUMNS }); }
Available Markers
// AUTO-GEN-4-AUTH// AUTO-GEN: Placeholder// AUTH-SCAFFOLD-MISSING-COLUMNS
You can quickly search these markers (Ctrl/Cmd+Shift+F) to locate auto-generated code and remove them after review.
❓ Why use this package?
Compared to Laravel Breeze, Jetstream or Fortify:
- ✅ Supports any number of auth models (not just
User) - ✅ Works in both standard and modular architectures
- ✅ Auth flow is fully generated and flexible for customizing
- ✅ Designed for fast scaffolding with clean, extensible code
💡 Example Use Cases
- Build multi separate auths for User, Admin, Vendor... in one app
- Use in modular apps like Modules/User, Modules/Admin
- Rapid implementing for auth APIs
- Auto-generate secure & clean Laravel auth structure
🚫 Limitations
- Does not include frontend assets like Vue/React.
- For OTP/email verification, you need to configure mail/notification system.
✅ Requirements
- PHP >= 8.0
- Laravel 11 / 12
- Composer
- Optional:
Laravel Sanctum - Optional:
nwidart/laravel-modules
📄 License
MIT © Nguyễn Trí Quang
🙌 Contributing
PRs are welcome! Feel free to improve functionality or report issues via GitHub Issues.
📬 Contact
- GitHub: github.com/ntquangkk
- Email: ntquangkk@gmail.com
triquang/laravel-auth-scaffold 适用场景与选型建议
triquang/laravel-auth-scaffold 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「Authentication」 「module」 「laravel」 「ddd」 「modular」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 triquang/laravel-auth-scaffold 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 triquang/laravel-auth-scaffold 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 triquang/laravel-auth-scaffold 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Automatically logs-in users if they are already authenticated by a remote source. (e.g. environment variable REMOTE_USER)
GraphQL authentication for your headless Craft CMS applications.
Laravel middleware to restrict a site or specific routes using HTTP basic authentication
Email Toolkit Plugin for CakePHP
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-01