Download the PHP package laraneat/modules without Composer
On this page you can find all versions of the php package laraneat/modules. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laraneat/modules
More information about laraneat/modules
Files in laraneat/modules
Package modules
Short Description Laraneat modules.
License MIT
Homepage https://github.com/laraneat/modules/
Informations about the package modules
Laraneat Modules
A Laravel package that provides a powerful modular architecture system for organizing large-scale applications into self-contained, reusable modules.
Table of Contents
- Overview
- Performance Comparison
- Architecture Diagram
- Installation
- Quick Start
- Module Structure
- Core Concepts
- Configuration
- Artisan Commands
- Component Types
- Module Presets
- Best Practices
Overview
Laraneat Modules helps you build maintainable, scalable Laravel applications. Inspired by the Porto SAP (Software Architectural Pattern), it encourages organizing code by business domains (modules) instead of technical layers.
Why Modular Architecture?
| Traditional Laravel | Modular Approach |
|---|---|
All controllers in app/Http/Controllers |
Each module has its own controllers |
All models in app/Models |
Each module has its own models |
| Coupled, hard to maintain | Decoupled, easy to maintain |
| Difficult to reuse | Easy to extract and reuse |
| Complex routing | Module-scoped routing |
Performance Comparison with nWidart/laravel-modules
This package is designed with performance in mind. With caching enabled, it adds virtually zero overhead — the cached manifest is a simple PHP array that loads in microseconds, and all core services use lazy loading.
Here's how it compares to the popular nWidart/laravel-modules:
Key Differences
| Feature | Laraneat Modules | nWidart/laravel-modules |
|---|---|---|
| Module manifest | composer.json only |
module.json + composer.json |
| Cache type | Persistent file cache | In-memory only (per request) |
| Service providers | DeferrableProvider (lazy) | Eager loading |
| Enable/disable modules | Not supported | Supported via JSON file |
| Architecture pattern | Domain-driven (Porto-inspired) | Flexible structure |
Performance Impact
Production (with cache enabled)
| Metric | Laraneat | nWidart |
|---|---|---|
| File operations (first request) | 1 (cached manifest) | N (module.json × modules) |
| File operations (subsequent) | 1 | N |
| Providers loaded | On-demand | All modules |
Development (without cache)
Both packages scan the filesystem on each request. However, Laraneat uses DeferrableProvider, so the ModulesRepository is only instantiated when actually needed.
Why Laraneat is Faster
-
Persistent manifest cache — Module metadata is cached to
bootstrap/cache/laraneat-modules.php, eliminating filesystem scans in production. -
DeferrableProvider — Core services (
ModulesRepository,Composer, console commands) implement Laravel'sDeferrableProviderinterface, loading only when requested. -
Single manifest file — Uses existing
composer.jsoninstead of requiring an additionalmodule.jsonper module. - No status file I/O — No
modules_statuses.jsonreads on every request (unlike nWidart's enabled/disabled feature).
Recommendations
After deployment:
For development with many modules, consider enabling cache manually to avoid repeated filesystem scans.
Architecture Diagram
Module Internal Architecture
Request Flow Through Module
Actions serve as controllers using the lorisleiva/laravel-actions package. Each Action has two entry points:
handle()- Core business logic (can be called from anywhere)asController()- HTTP entry point (receives Request, returns Response)
Example Action:
Installation
Publish the configuration file:
Quick Start
1. Create Your First Module
This creates a new module at modules/blog/ with basic structure.
2. Create Module with Full API
This creates a complete REST API module with:
- Controllers for CRUD operations
- Request validation classes
- API resources for JSON responses
- Database migrations and seeders
- Complete test suite
3. Generate Components
4. Run Module Migrations
Module Structure
A complete module follows this structure:
Core Concepts
Module
A Module represents a self-contained business domain. It's identified by its Composer package name (e.g., app/blog).
ModulesRepository
The ModulesRepository discovers and manages all modules in your application.
Actions
Actions are the core of the architecture. Using lorisleiva/laravel-actions, they serve dual purposes:
- Business Logic via
handle()method - can be called from anywhere (other actions, jobs, commands) - HTTP Controller via
asController()method - handles HTTP requests directly
Routes point directly to Actions:
DTOs (Data Transfer Objects)
DTOs are simple objects that carry data between layers.
Module Service Provider
Each module has a service provider that extends ModuleServiceProvider:
Configuration
After publishing, edit config/modules.php:
Artisan Commands
Module Management
| Command | Description |
|---|---|
module:list |
Display all registered modules |
module:sync |
Refresh manifest and sync with Composer |
module:delete {package} |
Delete a module completely |
module:cache |
Build module manifest cache |
module:cache:clear |
Clear module manifest cache |
Module Creation
Component Generators
| Command | Description |
|---|---|
module:make:action |
Create an Action class |
module:make:controller |
Create a Controller (--ui=api|web) |
module:make:model |
Create an Eloquent Model |
module:make:migration |
Create a database migration |
module:make:request |
Create a Form Request |
module:make:resource |
Create an API Resource |
module:make:dto |
Create a DTO class |
module:make:event |
Create an Event class |
module:make:listener |
Create an Event Listener |
module:make:job |
Create a Job class |
module:make:policy |
Create a Policy class |
module:make:provider |
Create a Service Provider |
module:make:middleware |
Create Middleware |
module:make:command |
Create a Console Command |
module:make:factory |
Create a Model Factory |
module:make:seeder |
Create a Database Seeder |
module:make:test |
Create a Test class |
module:make:observer |
Create a Model Observer |
module:make:notification |
Create a Notification |
module:make:mail |
Create a Mailable |
module:make:rule |
Create a Validation Rule |
module:make:query-wizard |
Create a QueryWizard |
module:make:route |
Create a Route file |
module:make:exception |
Create an Exception class |
Migration Commands
| Command | Description |
|---|---|
module:migrate |
Run module migrations |
module:migrate:rollback |
Rollback module migrations |
module:migrate:reset |
Reset all module migrations |
module:migrate:refresh |
Refresh module migrations |
module:migrate:status |
Show migration status |
Component Types
The package supports 30+ component types organized by architectural layers:
UI Layer
API Components:
ApiController- REST API controllersApiRequest- API form requestsApiResource- API JSON resourcesApiRoute- API route filesApiQueryWizard- Query builder wrappersApiTest- API integration tests
WEB Components:
WebController- Web controllersWebRequest- Web form requestsWebRoute- Web route filesWebTest- Web integration tests
CLI Components:
CliCommand- Artisan commandsCliTest- Command tests
Domain Layer
Action- Business logic actionsModel- Eloquent modelsDto- Data Transfer ObjectsEvent- Domain eventsListener- Event listenersJob- Queued jobsRule- Validation rulesObserver- Model observers
Infrastructure Layer
Provider- Service providersMiddleware- HTTP middlewarePolicy- Authorization policiesMail- Mailable classesNotification- Notifications
Database Layer
Migration- Database migrationsSeeder- Database seedersFactory- Model factories
Module Presets
Plain Preset (Default)
Basic module with minimal structure:
- Service providers only
- Empty directory structure
Base Preset
Includes database layer components:
- Model with migrations
- Factory for testing
- Seeder with permissions
- Authorization policy
API Preset
Complete REST API module:
- All base preset components
- CRUD controllers
- Form requests (create, update, delete, list, view)
- API resources
- QueryWizard for filtering/sorting
- DTOs for data transfer
- Complete route file
- Full test coverage
Best Practices
1. Keep Modules Independent
Modules should be loosely coupled. If module A depends on module B, consider:
- Using events for communication
- Creating shared interfaces
- Moving shared code to a separate package
2. Separate HTTP Logic from Business Logic
Keep asController() thin - it should only handle HTTP concerns. Put business logic in handle():
3. Reuse Actions Across Contexts
Actions can be called from multiple places:
4. Use DTOs for Data Transfer
DTOs provide type safety and clear contracts:
5. Organize Routes by Version
For APIs, version your routes:
6. Write Tests
Each module should have comprehensive tests:
7. Use Caching in Production
Enable manifest caching for better performance:
Run after deployment:
License
MIT License. See LICENSE for details.
All versions of modules with dependencies
ext-json Version *
composer/composer Version ^2.1
laravel/framework Version ^10.0 || ^11.0 || ^12.0