billyranario/laravel-passport-boilerplate
Composer 安装命令:
composer require billyranario/laravel-passport-boilerplate
包简介
A Laravel package to quickly start a new project with Laravel Passport
README 文档
README
Description
LaravelBoilerPlate is a Laravel package that provides a set of tools to help you build APIs and web applications faster.
Requirements
- PHP version: 7.4 and above
- Laravel version: 6.0 and above
- Laravel Passport: ^12.0
- Billyranario Prostarter-Kit: ^1.0
Table of Contents
Installation
composer require laravel/passport composer require billyranario/prostarterkit php artisan vendor:publish --tag=passport-migrations php artisan vendor:publish --tag=prostarter-kit composer require billyranario/laravel-passport-boilerplate php artisan vendor:publish --tag=billyranario-boilerplate --force php artisan migrate
edit config/auth.php file
return [ ..., // Other config 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], // Add this following code below 'api' => [ 'driver' => 'passport', 'provider' => 'users', ], ], ];
php artisan passport:keys php artisan passport:client --password > psk-password-grant > [0] users php artisan passport:client --personal > psk-personal-access
Creating Superadmin
On your .env file, add the following code below. This will provide a default web url for your reset password form page.
The APP_ADMIN_PASS is the default password for creating an admin user. You can change it to your desired password.
If not specified, the default password is Abc@123456.
APP_WEB_URL=http://localhost:4202 APP_ADMIN_PASS=secret
Once everything is setup, you run the artisan command below to create an admin user.
php artisan admin:create
php artisan admin:create --super # to create a super admin
This will ask you a password to proceed. The password should match to the value you set in the APP_ADMIN_PASS in your .env file.
Admin:API Middleware Kernel.php
Open your app/Http/Kernel.php file and insert the following code below.
protected $middlewareAliases = [ // other aliases.... 'admin.api' => \App\Http\Middleware\Admin\AdminApi::class, // <- Insert this line ];
Setup UserObserver
EventServiceProvider.php Insert the following lines of codes below
use App\Models\User; use App\Observers\UserObserver; // INSIDE THE CLASS, ADD THIS /** * The model observers for your application. * * @var array */ protected $observers = [ User::class => [UserObserver::class], ];
Update Routes
RouteServiceProvider.php Insert the followwing
public function boot(): void { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); }); $this->routes(function () { Route::middleware('api') ->prefix('api') ->group(base_path('routes/api.php')); // INSERT THIS BLOCK Route::middleware('api') ->prefix('api/admin') ->group(base_path('routes/admin.php')); // END Route::middleware('web') ->group(base_path('routes/web.php')); }); }
Contributing
Contributions are welcome. Please submit a PR or open an issue.
License
This package is open-source and licensed under the MIT License.
billyranario/laravel-passport-boilerplate 适用场景与选型建议
billyranario/laravel-passport-boilerplate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 247 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 billyranario/laravel-passport-boilerplate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 billyranario/laravel-passport-boilerplate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 247
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-09