定制 creativitykills/api-starter-kit 二次开发

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

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

creativitykills/api-starter-kit

最新稳定版本:v0.0.4

Composer 安装命令:

composer create-project creativitykills/api-starter-kit

包简介

API starter kit for the Laravel framework

README 文档

README

Minimal Laravel starter kit aimed at accelerating API development with authentication, and comprehensive documentation tooling built in.

Whats Inside?

Authentication Ready

  • Laravel Fortify as the backend for user management
    • Create access token
    • Refresh access token
    • Revoke access token
  • Laravel Sanctum integration for API token management with refresh token support
  • Token-based authentication with configurable abilities and access levels

📚 Auto-Generated Documentation API Documentation

Postman Screenshot
  • Scribe integration with custom extensions for enhanced API docs
    • Improved Postman collection generation with pre-request script for automatic token generation for all endpoints
    • Supports environment variables in API Documentation
  • Structured response documentation with reusable classes (using Attributes)
  • Structured API Documentation with groups & subgroups (using Attributes)

🏗️ Optional Action-based Architecture

  • Action-based architecture for business logic
  • DTOs for type-safe data transfer

🧪 Testing Foundation

  • Pre-configured Pest testing setup, with existing tests for authentication
  • PHPStan for static analysis
  • PHP CS Fixer for code style

Quick Start

  1. Install using Laravel new command: See https://laravel.com/docs/12.x/starter-kits#community-maintained-starter-kits
    laravel new example-api --using=creativitykills/api-starter-kit
  2. Using Composer
    composer create-project creativitykills/api-starter-kit

Your API documentation will be available at /docs and your API endpoints will be ready for authentication and token management.

Default API Endpoints

  • POST /v1/auth/token/create - User authentication and token issuance
  • POST /v1/auth/token/refresh - Refresh access tokens
  • POST /v1/auth/token/revoke - Revoke access tokens

Project Structure

The starter kit remains largely unchanged from the original Laravel application. However, here are some of the notable changes that have been made to the project.

Click to expand project structure
api-starter-kit/
├── app/
│   ├── Actions/
│   │   ├── Fortify/                         # User management actions (Laravel Fortify)
│   │   └── Sanctum/                         # API token management actions (Laravel Sanctum)
│   │       └── IssueAccessToken.php         # This action can be used to issue API tokens 
│   ├── Contracts/                           # Interface definitions
│   │   └── SupportsDocumentation.php        # This interface is used to document API endpoints, usable in Requests & Actions
│   ├── Data/
│   │   ├── Enums/                           
│   │   │   ├── Abilities.php                # This enum is used to define the abilities of a user token
│   │   │   └── AccessLevel.php              # This enum is used to define groups of abilities as access levels
│   │   ├── IssueAccessTokenDto.php          # This class is a simple DTO for holding the data needed to issue a new access token
│   │   └── IssuedAccessTokenDto.php         # This class is a simple DTO for holding the data of an issued access token
│   ├── Extensions/
│   │   └── Scribe/                          # Here extend some parts of the Scribe package to allow for even better documentation
│   │       ├── Concerns/
│   │       │   └── ExtendableAttributeNames.php
│   │       ├── Config/
│   │       │   └── Defaults.php
│   │       ├── Extracting/
│   │       │   └── Strategies/               # Extend the strategies to allow for custom responses and documentation groups
│   │       │       ├── Metadata/
│   │       │       │   ├── GetFromDocBlocks.php
│   │       │       │   ├── GetFromMetadataAttributes.php
│   │       │       │   └── GetValidationRulesFromAction.php
│   │       │       └── Response/
│   │       │           └── UseResponseAttributes.php
│   │       └── Writing/                      # Added support for generating even better Postman collections with pre-request scripts
│   │           ├── Postman/
│   │           │   ├── PostmanCollectionWriter.php
│   │           │   ├── PostmanEndpointProcessor.php
│   │           │   └── Processors/           # Processors allow you even greater control over the Postman collection
│   │           │       ├── CreateTokenEndpointProcessor.php
│   │           │       ├── EndpointProcessor.php
│   │           │       └── RefreshTokenEndpointProcessor.php
│   │           └── Writer.php
│   ├── Http/
│   │   ├── [...]
│   │   ├── Documentation/                     # API documentation structure classes
│   │   │   ├── Groups/                        # API Documentation groups
│   │   │   │   ├── AuthenticationGroup.php    
│   │   │   │   ├── GenericGroup.php           
│   │   │   │   └── GenericSubgroup.php        
│   │   │   └── Responses/                     # API Response documentation classes
│   │   │       ├── Authentication/
│   │   │       │   └── AccessTokenResponse.php # Response documentation for access tokens
│   │   │       ├── BadRequestResponse.php
│   │   │       ├── CreatedResponse.php
│   │   │       ├── [...]
│   │   │       ├── UnauthorizedResponse.php
│   │   │       └── UnprocessableEntityResponse.php
│   │   └── [...]         
│   └── [...]           
└── [...]   

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-30