kadevland / easy-modules
Organize your Laravel application into modules following the Clean Architecture. 30+ commands for fast modular development.
Fund package maintenance!
kadevland
Requires
- php: ^8.2
- illuminate/console: ^12.0
- illuminate/filesystem: ^12.0
- illuminate/support: ^12.0
Requires (Dev)
- laravel/pint: ^1.0
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-05-25 20:19:39 UTC
README
โ ๏ธ Development Status: This package is currently in active development (v0.3.0). While functional, some features may change before the stable release.
Easy Module is a Laravel package that enables you to organize your application using modular architecture. Generate organized, maintainable applications with automatic component registration and structured code separation. Clean Architecture configuration is provided as a ready-to-use setup.
โจ Key Features
- ๐๏ธ Modular Structure - Organized application architecture with configurable layers
- โก Auto-Generation - Create complete modules with one command
- ๐ Auto-Discovery - Automatic module registration and loading
- ๐ฏ Extensible - Add custom scaffold files and components
- ๐ Easy to Use - Simple commands with intelligent defaults
- ๐๏ธ Clean Architecture Ready - Pre-configured setup for Domain, Application, Infrastructure, and Presentation layers
- ๐ Laravel 12 Ready - Full compatibility with Laravel 12's latest features
๐ Installation & Quick Start
Requirements
- Laravel 12+ - Built specifically for Laravel 12
- PHP 8.2+ - Required by Laravel 12
- Composer - For package management
Installation
Install via Composer:
composer require --dev kadevland/easy-modules
Publish configuration:
# Default way php artisan vendor:publish --provider="Kadevland\EasyModules\EasyModulesServiceProvider" --tag="config" # Using Easy Module command php artisan easymodules:publish # Publish with options php artisan easymodules:publish --all # Config & stubs php artisan easymodules:publish --stubs # Stubs only php artisan easymodules:publish --force # Force overwrite
Create your first module:
# Single module php artisan easymodules:new Blog # Multiple modules php artisan easymodules:new Blog User Product # Using aliases php artisan emodules:new Shop php artisan emodule:new Auth
๐ ๏ธ Commands & Generators
EasyModules provides 29 powerful commands for rapid development:
- ๐ง 4 Utility commands - Module creation, publishing, module listing, flexible generation
- ๐๏ธ3 Clean Architecture commands - Entities, services, and custom components
- ๐ 22 Laravel-compatible commands - All Laravel generators, module-aware
๐ Complete Command Reference Guide - Full documentation with examples
Quick Examples
# Create a complete blog module php artisan easymodules:new Blog # Generate Clean Architecture components php artisan easymodules:make-entity Blog Post php artisan easymodules:make-service Blog PostService # Use familiar Laravel commands in modules php artisan easymodules:make-model Blog Post --migration --factory # Flexible Clean Architecture generation php artisan easymodules:make-stub Blog UserRepository repository php artisan easymodules:make-stub Shop OrderDTO dto php artisan easymodules:make-stub User EmailValueObject valueobject # List discovered modules php artisan easymodules:list --routes
Command Aliases
All commands support these prefixes:
easymodules:
(full)emodules:
(short)emodule:
(shortest)
๐๏ธ What Gets Generated
When you run:
php artisan easymodules:new Blog
app/Modules/Blog/
โโโ Application/
โ โโโ Actions/
โ โโโ DTOs/
โ โโโ Interfaces/
โ โโโ Mappers/
โ โโโ Rules/
โ โโโ Services/
โ โโโ Validation/
โโโ Domain/
โ โโโ Entities/
โ โโโ Services/
โ โโโ ValueObjects/
โโโ Infrastructure/
โ โโโ Casts/
โ โโโ Exceptions/
โ โโโ Mappers/
โ โโโ Models/
โ โโโ Persistences/
โ โโโ Services/
โโโ Presentation/
โ โโโ Console/
โ โ โโโ Commands/
โ โโโ Http/
โ โ โโโ Controllers/
โ โ โโโ Middlewares/
โ โ โโโ Requests/
โ โ โโโ Resources/
โ โโโ Mappers/
โ โโโ Views/
โ โ โโโ Components/
โ โโโ resources/
โ โโโ views/
โโโ Database/
โ โโโ Factories/
โ โโโ Migrations/
โ โโโ Seeders/
โโโ Tests/
โ โโโ Feature/
โ โโโ Unit/
โโโ Providers/
โ โโโ BlogServiceProvider.php
โโโ config/
โ โโโ config.php
โโโ routes/
โ โโโ api.php
โ โโโ console.php
โ โโโ web.php
โโโ lang/
Plus these files are auto-generated:
- BlogServiceProvider.php - Automatically registered with Laravel
- config/config.php - Module-specific configuration
- routes/*.php - Route files with example routes
- All folder structure following Clean Architecture principles
โ๏ธ Configuration & Customization
Flexible configuration in config/easymodules.php
return [ // Module location and namespace 'base_path' => app_path('Modules'), 'base_namespace' => 'App\\Modules', // Laravel 12 auto-discovery 'auto_discover' => true, // Custom paths per component 'paths' => [ 'controller' => 'Presentation/Http/Controllers', 'model' => 'Infrastructure/Models', 'entity' => 'Domain/Entities', 'service' => 'Application/Services', // ... ], // Custom stubs 'stubs' => [ 'controller' => 'easymodules/controller.stub', 'entity' => 'easymodules/entity.stub', // ... ] ];
Customizable stubs
# Publish stubs for customization php artisan easymodules:publish --stubs # Modify in resources/stubs/easymodules/
๐ Laravel 12 Auto-Discovery
EasyModules integrates perfectly with Laravel 12:
โ Automatic registration of ServiceProviders โ Route discovery for web, API and console โ Module configuration loading โ Asset support with Vite
# See all discovered modules
php artisan easymodules:list --routes
๐งช Testing Configuration
PHPUnit
<!-- phpunit.xml --> <testsuites> <testsuite name="Feature"> <directory suffix="Test.php">./tests/Feature</directory> <directory suffix="Test.php">./app/Modules/*/Tests/Feature</directory> </testsuite> <testsuite name="Unit"> <directory suffix="Test.php">./tests/Unit</directory> <directory suffix="Test.php">./app/Modules/*/Tests/Unit</directory> </testsuite> </testsuites>
Pest
// tests/Pest.php uses(Tests\TestCase::class)->in('Feature', 'Unit'); uses(Tests\TestCase::class)->in('app/Modules/*/Tests/Feature'); uses(Tests\TestCase::class)->in('app/Modules/*/Tests/Unit');
๐ง Vite Integration (Laravel 12)
// vite.config.js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import { glob } from 'glob'; const moduleAssets = [ ...glob.sync('app/Modules/*/Presentation/resources/js/**/*.js'), ...glob.sync('app/Modules/*/Presentation/resources/css/**/*.css'), ]; export default defineConfig({ plugins: [ laravel({ input: [ 'resources/css/app.css', 'resources/js/app.js', ...moduleAssets, ], refresh: [ 'app/Modules/*/Presentation/resources/views/**', 'app/Modules/*/routes/**', ], }), ], });
๐ ๏ธ Benefits of Modular Architecture
โ Separation of Concerns
- Domain : Pure business logic, independent
- Application : Use cases and orchestration
- Infrastructure : Persistence and external services
- Presentation : User interface and APIs
โ Maintainability
- Code organized by functionality
- Isolated and fast tests
- Easier team development
โ Scalability
- Add features without impact
- Independent and reusable modules
- Possibility to extract into packages
๐ Complete Documentation
- ๐ Command Guide - Complete reference for 30+ commands
- ๐ง Configuration Guide - Advanced customization
- ๐๏ธ Architecture Templates - Future multi-pattern feature
๐ค Contributing
Contributions are welcome! Please see contributing guide.
๐ Changelog
Please see CHANGELOG for more information on recent changes.
๐ Security
For security issues, please email kadevland@kaosland.net.
๐ License
Open-source package under MIT license.
๐จโ๐ป Credits
- Kadevland - Creator and maintainer
- Contributors - Thank you for your contributions!
Made with โค๏ธ by Kadevland
โญ Star us on GitHub if this project helps you!
Laravel Easy Modules - Your modular architecture in 30 seconds ๐