定制 joesu/laravel-scaffold 二次开发

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

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

joesu/laravel-scaffold

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

joesu/laravel-scaffold 适用场景与选型建议

joesu/laravel-scaffold 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 114 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「generator」 「api」 「pattern」 「repository」 「boilerplate」 「service」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 joesu/laravel-scaffold 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 joesu/laravel-scaffold 我们能提供哪些服务?
定制开发 / 二次开发

基于 joesu/laravel-scaffold 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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