joesu/laravel-scaffold

A powerful Laravel package that provides a complete implementation of Repository and Service patterns for rapid API development.

Installs: 110

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 0

Forks: 2

pkg:composer/joesu/laravel-scaffold

v1.1.3 2025-06-28 03:40 UTC

This package is auto-updated.

Last update: 2025-12-15 16:43:18 UTC


README

From 0 to Complete API in 30 Seconds - Auto-generate Repository, Service, Controller with Laravel best practices

PHP Version Laravel Version License Tests

Solve the Problem: Eliminate repetitive CRUD code and implement enterprise-grade architecture patterns in Laravel development.

🎯 Why Choose Laravel Scaffold?

Feature Laravel Scaffold Other Packages
Repository Pattern βœ… Complete implementation ❌ Basic only
Service Layer βœ… Business logic separation ❌ Missing
Auto Setup βœ… Routes & bindings ❌ Manual setup
Multilingual Support βœ… Built-in EN/CN ❌ English only
Advanced Features βœ… Filtering, sorting, batch ops ❌ Limited
Clean Architecture βœ… Interface contracts ❌ Direct coupling

πŸš€ Quick Start

# Install the package
composer require joesu/laravel-scaffold

# Generate complete CRUD architecture
php artisan make:repository User

# That's it! Your API is ready to use

30 seconds later, you have a complete User API with enterprise architecture!

🎯 Perfect For

  • βœ… Enterprise API Development - Production-ready architecture
  • βœ… SaaS Backend Systems - Scalable service layer
  • βœ… Rapid Prototyping - Quick MVP development
  • βœ… Team Collaboration - Consistent code patterns
  • βœ… Code Quality - Clean architecture patterns

πŸ—οΈ Architecture

Laravel Scaffold provides a complete layered architecture with enterprise-grade patterns:

Base Classes

  • BaseRepository: Full CRUD implementation with advanced features
  • BaseService: Business logic layer with batch operations

Generated Structure

When you run php artisan make:repository User, you get:

app/
β”œβ”€β”€ Models/
β”‚   └── User.php                    # Eloquent Model
β”œβ”€β”€ Http/
β”‚   β”œβ”€β”€ Controllers/
β”‚   β”‚   └── UserController.php      # API Controller
β”‚   └── Requests/
β”‚       └── User/                   # Request validation classes
β”‚           β”œβ”€β”€ StoreUserRequest.php    # Store validation
β”‚           β”œβ”€β”€ UpdateUserRequest.php   # Update validation
β”‚           β”œβ”€β”€ IndexUserRequest.php    # Index validation
β”‚           └── ShowUserRequest.php     # Show validation
β”œβ”€β”€ Repositories/
β”‚   └── UserRepository.php          # Extends BaseRepository
β”œβ”€β”€ Services/
β”‚   └── UserService.php             # Extends BaseService
└── Contracts/
    β”œβ”€β”€ UserRepositoryInterface.php # Repository contract
    └── UserServiceInterface.php    # Service contract

Automatic Setup:

  • βœ… Service Provider Bindings: Automatically added to AppServiceProvider
  • βœ… API Routes: Automatically added to routes/api.php
  • βœ… Dependency Injection: Ready to use with Laravel's DI container

✨ Key Features

πŸ”„ Advanced Repository Features

  • Complete CRUD operations with error handling
  • Advanced query methods with relationship loading
  • Smart filtering system (JSON and array formats)
  • Relationship field filtering (e.g., 'user.name')
  • Configurable sorting with whitelist protection
  • Batch operations (create, update, delete)
  • Soft delete support with restore functionality
  • Multilingual error messages (EN/CN)

πŸŽ›οΈ Service Layer Features

  • Business logic encapsulation
  • Batch operations with transaction support
  • Utility methods (updateOrCreate, exists, count)
  • Soft delete operations
  • Error handling with custom exceptions

πŸ› οΈ Installation & Setup

1. Install Package

composer require joesu/laravel-scaffold

2. Publish Configuration (Optional)

php artisan vendor:publish --provider="JoeSu\LaravelScaffold\Providers\LaravelScaffoldServiceProvider"

3. Generate Your First CRUD

# Complete CRUD generation with automatic setup
php artisan make:repository User

# Include migration file
php artisan make:repository User --migration

# Include request validation classes
php artisan make:repository User --requests

# Include both migration and requests
php artisan make:repository User --migration --requests

# Force overwrite existing files
php artisan make:repository User --force

What happens automatically:

  • βœ… Model is always created (needed for Repository and Service)
  • βœ… Service provider bindings are added to AppServiceProvider
  • βœ… API routes are added to routes/api.php
  • βœ… All files are properly namespaced and ready to use
  • βœ… No manual configuration required

Available Options:

  • --migration: Create migration file
  • --requests: Create request validation classes
  • --force: Overwrite existing files

🌍 Multilingual Support

Built-in support for multiple languages with automatic error message translation:

Supported Languages

  • πŸ‡ΊπŸ‡Έ English (en)
  • πŸ‡ΉπŸ‡Ό Chinese Traditional (zh-TW)

Publishing Language Files

# Publish all language files
php artisan vendor:publish --provider="JoeSu\LaravelScaffold\Providers\LaravelScaffoldServiceProvider" --tag=lang

Error Message Examples

// English
"Record with ID 123 not found"
"Failed to create model: SQLSTATE[23000]: Integrity constraint violation"

// Chinese Traditional (when locale is zh-TW)
"ζ‰ΎδΈεˆ° ID η‚Ί 123 ηš„θ¨˜ιŒ„"
"ε»Ίη«‹ζ¨‘εž‹ε€±ζ•—: SQLSTATE[23000]: Integrity constraint violation"

πŸ”§ Configuration

The package automatically registers service providers and bindings. For custom configuration:

# Publish config file
php artisan vendor:publish --provider="JoeSu\LaravelScaffold\Providers\LaravelScaffoldServiceProvider"

πŸ§ͺ Testing

# Run package tests
composer test

# Run with coverage
composer test-coverage

πŸ“‹ Requirements

  • PHP: ^8.1|^8.2|^8.3|^8.4
  • Laravel: ^10.0|^11.0|^12.0

πŸ”„ Version Compatibility

Laravel Version PHP Version Status
10.x ^8.1 βœ… Supported
11.x ^8.2 βœ… Supported
12.x ^8.2 βœ… Supported

For detailed version compatibility, see VERSION_COMPATIBILITY.md.

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

πŸ“„ License

This package is open-sourced software licensed under the MIT License.

πŸ†˜ Support

⭐ Show Your Support

If this package helps you, please give it a ⭐ on GitHub!

Built with ❀️ for the Laravel community