myboilerplate/core-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

myboilerplate/core-api

Composer 安装命令:

composer require myboilerplate/core-api

包简介

DDD Auth core for Laravel APIs — register, login, JWT, profile, password reset out of the box.

README 文档

README

Laravel package providing a complete DDD-based authentication core:

  • User registration & login (JWT)
  • Token refresh & logout
  • Profile update (name + password)
  • Password reset via email
  • Rate limiting, security headers, CORS

Requirements

  • PHP 8.2+
  • Laravel 12+
  • tymon/jwt-auth ^2.2

Installation

1. Require the package

composer require myboilerplate/core-api

The service provider is auto-discovered — no manual registration needed.

2. Publish migrations and run them

php artisan vendor:publish --tag=core-api-migrations
php artisan migrate

4. Generate JWT secret

php artisan jwt:secret

5. Add environment variables

JWT_SECRET=<generated above>
JWT_TTL=60
JWT_REFRESH_TTL=20160
JWT_BLACKLIST_ENABLED=true
CORS_ALLOWED_ORIGINS=http://localhost:3000

API Endpoints

All endpoints are prefixed with /api/v1 by default.

MethodEndpointAuthDescription
GET/api/v1/healthNoHealth check
POST/api/v1/auth/registerNoRegister a new user
POST/api/v1/auth/loginNoLog in, receive JWT
POST/api/v1/auth/logoutBearer tokenInvalidate token
POST/api/v1/auth/refreshBearer tokenRefresh token
GET/api/v1/auth/meBearer tokenCurrent user info
PATCH/api/v1/auth/meBearer tokenUpdate profile (name / password)
POST/api/v1/auth/forgot-passwordNoRequest password reset email
POST/api/v1/auth/reset-passwordNoReset password with token

Customisation

Change the route prefix

CORE_API_PREFIX=api/v2

Disable built-in routes (to define your own)

php artisan vendor:publish --tag=core-api-routes

Then set CORE_API_ROUTES=false in .env and load/customise routes/core-api.php yourself.

Override rate limits

CORE_API_RL_LOGIN=5
CORE_API_RL_REGISTER=10
CORE_API_RL_FORGOT=3
CORE_API_RL_RESET=5

Or publish the config for full control:

php artisan vendor:publish --tag=core-api-config

Running Package Tests

composer install
vendor/bin/phpunit

Or with specific suites:

vendor/bin/phpunit --testsuite Domain
vendor/bin/phpunit --testsuite Application
vendor/bin/phpunit --testsuite Infrastructure
vendor/bin/phpunit --testsuite Feature

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固