creativitykills/api-starter-kit

API starter kit for the Laravel framework

v0.0.4 2025-08-30 18:56 UTC

This package is auto-updated.

Last update: 2025-08-30 18:56:36 UTC


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
โ”‚   โ”‚   โ””โ”€โ”€ [...]         
โ”‚   โ””โ”€โ”€ [...]           
โ””โ”€โ”€ [...]