Skip to content

A clean, scalable Laravel 12 API boilerplate with SOLID architecture, CRUD generators, Docker, Passport, and automated code quality tools.

License

Notifications You must be signed in to change notification settings

alaa-nabawy/laravel-solid-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

42 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Laravel API SOLID

PHP Version Laravel Version Docker Ready CI License

About

Laravel API SOLID Boilerplate is a production-ready starter kit for secure, scalable Laravel APIs. Built on SOLID principles, it includes automated CRUD scaffolding, Passport OAuth2 authentication, Dockerized environments, and a CI pipeline that enforces code quality before every commit. Start new projects in hours, not weeks β€” with confidence your base is built to last.

Table of Contents

Features

πŸ—οΈ SOLID Architecture

  • Repository pattern with service layer separation
  • Dependency injection and interface-based design
  • Clean, maintainable, and testable code structure

⚑ Enhanced CRUD Generation

  • make:structure command with selective generation (--only, --no-resource)
  • make:route-group for organized API endpoints
  • Modern PHP 8.2+ syntax with constructor property promotion

πŸ” Laravel Passport Integration

  • OAuth2 authentication out of the box
  • Automated setup scripts
  • API token management

🐳 Professional Docker Setup

  • Separate development and production environments
  • PostgreSQL, Redis, MailHog integration
  • Optimized for cloud deployment

πŸ”§ Comprehensive Code Quality

  • Pre-commit hooks: PHPStan, Pint, PHPUnit, security audit
  • Automated testing with coverage reports
  • Markdown linting and secret detection

πŸš€ Workflow Automation

  • Complete Makefile with 30+ commands
  • One-command setup and deployment
  • Integrated development tools

Quick Start

Development Setup

# Clone and setup
git clone <repository-url>
cd laravel-api-solid

# One-command setup (includes Docker, dependencies, migrations, Passport)
make setup

# Start development environment
make dev

# Access workspace for Laravel commands
make shell

Your API will be available at http://localhost:8000 with MailHog at http://localhost:8025.

Production Deployment

# Configure environment
cp .env.prod .env
nano .env  # Edit production settings

# Deploy
make prod-build

Essential Commands

# Development
make dev              # Start development environment
make shell            # Access workspace container
make migrate          # Run database migrations
make test             # Run test suite
make code-quality     # Run all quality checks

# Code Quality
make phpstan          # Static analysis
make code-style       # Fix code formatting
make test-coverage    # Tests with coverage
make security-audit   # Security scan

# Passport
make passport-setup   # Complete Passport setup
make passport-client  # Create OAuth client

Enhanced CRUD Generation

Powerful Artisan commands for rapid API development with SOLID architecture.

Commands

# Generate complete CRUD structure
php artisan make:structure User

# Selective generation (only specific methods)
php artisan make:structure Post --only=index,show,store

# Skip resource folder creation
php artisan make:structure Category --no-resource

# Generate organized route groups
php artisan make:route-group Api/V1/Users

What Gets Generated

  • Repository & Interface: Data access layer with contracts
  • Service Classes: Business logic separation (Create, Read, Update, Delete)
  • Controller: Clean, dependency-injected API controller
  • Resources: API response transformers (optional)
  • Routes: Organized route groups with automatic registration

πŸ“– Complete Documentation - Detailed examples and advanced usage

Code Quality & Pre-commit Hooks

Comprehensive automated code quality enforcement with pre-commit hooks.

Tools Included

  • PHPStan: Static analysis and type checking
  • Laravel Pint: Code style formatting
  • PHPUnit: Automated testing with coverage
  • Composer Audit: Security vulnerability scanning
  • Secret Detection: Prevent credential commits
  • Markdown Linting: Documentation quality

Setup

# Setup pre-commit hooks (included in make setup)
make setup-pre-commit

# Manual quality checks
make full-quality-check  # Complete analysis
make phpstan            # Static analysis only
make code-style         # Fix formatting
make test-coverage      # Tests with coverage
make security-audit     # Security scan

Pre-commit hooks automatically run on every commit, ensuring consistent code quality across the team.

πŸ“– Pre-commit Setup Guide | πŸ“– Code Quality Tools

Docker Environment

Professional Docker setup with separate development and production configurations.

Development Stack

  • PostgreSQL: Primary database
  • Redis: Caching and sessions
  • MailHog: Email testing
  • Workspace: Full development environment with tools

Production Stack

  • Nginx: Web server
  • PHP-FPM: Optimized PHP processing
  • PostgreSQL: Production database
  • Redis: Production caching
# Development
make dev              # Start development stack
make shell            # Access workspace
make db-shell         # Access PostgreSQL

# Production
make prod-build       # Build and deploy production
make prod-logs        # View production logs

πŸ“– Complete Docker Documentation

Authentication

Laravel Passport OAuth2 implementation with automated setup.

Features

  • OAuth2 server with personal access tokens
  • API authentication middleware
  • Automated client and key generation
  • Production-ready configuration

Setup

# Automatic setup (included in make setup)
make passport-setup

# Manual setup
make passport-install
make passport-keys
make passport-client

πŸ“– Passport Setup Guide

Frontend Integration

Modern frontend development with Vue.js or React, featuring Inertia.js for seamless full-stack integration.

Quick Setup

# Setup Vue 3 with Inertia.js
make setup-vue

# Setup React 18 with Inertia.js
make setup-react

# Start development environment
make dev

Framework Options

Vue.js 3 Stack:

  • Vue 3 with Composition API
  • Pinia for state management
  • Vue Router for client-side routing
  • Vitest for testing

React 18 Stack:

  • React 18 with hooks
  • Redux Toolkit for state management
  • React Router for client-side routing
  • Jest for testing

Shared Technologies:

  • Inertia.js for server-side routing
  • Vite for fast development and building
  • Tailwind CSS for styling
  • TypeScript support
  • Headless UI components
  • Docker integration

Development Workflow

# Access workspace for frontend development
make shell

# Inside workspace:
npm run dev     # Start Vite dev server with HMR
npm run build   # Build for production
npm run test    # Run component tests
npm run lint    # Lint and format code
npm run type-check  # TypeScript checking

πŸ“– Complete Frontend Documentation - Comprehensive guides for Vue.js, React, setup, deployment, and advanced configuration

Documentation

Comprehensive guides available in the docs/ directory:

Backend & Architecture

Frontend Development

DevOps & Quality

πŸ“– Documentation Index

License: MIT | PHP: 8.2+ | Laravel: 12.0+

About

A clean, scalable Laravel 12 API boilerplate with SOLID architecture, CRUD generators, Docker, Passport, and automated code quality tools.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published