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
Requires
- php: ^8.1|^8.2|^8.3|^8.4
- laravel/framework: ^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^10.0
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
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
- π§ Issues: GitHub Issues
- π Documentation: GitHub Wiki
- π¬ Discussions: GitHub Discussions
β Show Your Support
If this package helps you, please give it a β on GitHub!
Built with β€οΈ for the Laravel community