joesu/laravel-scaffold 问题修复 & 功能扩展

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

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

joesu/laravel-scaffold

最新稳定版本:v1.1.3

Composer 安装命令:

composer require joesu/laravel-scaffold

包简介

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

README 文档

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-27