Download the PHP package andrebhas/laravel-brick without Composer
On this page you can find all versions of the php package andrebhas/laravel-brick. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrebhas/laravel-brick
More information about andrebhas/laravel-brick
Files in andrebhas/laravel-brick
Package laravel-brick
Short Description Build modular monolith Laravel applications with a solid foundation. Each module is a 'brick' that can be stacked wisely. Includes an optional internal bridge with async support, circuit breaker, and Pest testing.
License MIT
Informations about the package laravel-brick
๐งฑ Laravel Brick
Build modular Laravel applications with a solid foundation. Each module is an independent, self-contained unit (a "brick") that can be composed into robust, scalable applications using Domain-Driven Design principles.
"Each module is a brick. Stack them wisely."
โจ Features
| Feature | Description |
|---|---|
| ๐ Modular Core | Create isolated modules with a standard DDD structure |
| ๐ Internal Bridge | Optional typed, validated cross-module communication |
| โก Async Calls | Dispatch bridge calls to queues, poll results by job ID |
| ๐ก Circuit Breaker | Protect against cascading failures (closed/open/half-open) |
| ๐ Middleware Pipeline | Logging, circuit breaker, caching per bridge call |
| ๐งช Pest Testing | Auto-generate test scaffolding with every module |
| ๐ฆ Module Dependencies | Modules declare dependencies; enable/disable with checks |
| โ๏ธ Per-Module Config | Each module has its own Config/config.php |
| ๐จ Asset Publishing | Copy or symlink module assets to public/bricks/ |
| ๐ Octane Compatible | No static state; fully safe for Laravel Octane |
๐ Requirements
- PHP 8.1 or higher
- Laravel 9.x, 10.x, or 11.x
๐ฆ Installation
The package uses Laravel's auto-discovery. The service provider is registered automatically.
Publish Configuration
Publish Stubs (optional, to customise scaffolding)
๐ Module Structure
Layer-Driven Architecture (Default)
After running php artisan brick:make, each module follows this structure:
Feature-Driven Architecture
If you prefer to organizer your module by business features rather than technical layers, you can use the --features flag (or answer yes during the interactive prompt). This replaces the Actions directory with a Features directory:
๐ Quick Start
1. Create a Module
Interactive flow:
Or non-interactively:
2. Register the Module's Namespace
Add to composer.json:
Then regenerate autoload:
3. Enable the Module
4. Run Migrations
๐ Module Manifest (module.json)
๐ Bridge: Cross-Module Communication
1. Implement the Bridge
2. Synchronous Call (from another module)
3. Asynchronous Call
4. Generate Bridge for Existing Module
๐ก Circuit Breaker
The circuit breaker prevents cascading failures when a module's bridge is unreliable.
States
- Closed ๐ข โ Normal operation; calls pass through
- Open ๐ด โ Failures exceeded threshold; calls rejected immediately
- Half-Open ๐ก โ Testing recovery with limited trial calls
Configuration (config/brick.php)
Status Command
Manual Reset
๐งช Testing
Package Tests
Module Tests (Pest)
Each generated module includes its own tests directory with Pest setup:
Testing Helpers
BridgeFake โ Mock bridge calls in tests
CircuitBreakerFake โ Simulate circuit states
Generate Test File
๐ฎ Artisan Commands Reference
| Command | Description |
|---|---|
brick:make |
Create a new module interactively |
brick:make-feature {module} {feature} |
Scaffold a full feature (Action, Request, etc) |
brick:make-action {module} {name} |
Generate an Action class |
brick:make-request {module} {name} |
Generate a FormRequest class |
brick:make-response {module} {name} |
Generate a Response/Resource class |
brick:make-job {module} {name} |
Generate a specific Job |
brick:make-event {module} {name} |
Generate an Event |
brick:make-listener {module} {name} |
Generate a Listener |
brick:make-bridge {module} |
Generate bridge for a module |
brick:make-test {module} {name} |
Generate a Pest test file |
brick:bridge:status |
Show circuit breaker status for all bridges |
brick:enable {module} |
Enable a module (checks dependencies) |
brick:disable {module} |
Disable a module (checks dependents) |
brick:publish-assets {module?} |
Publish module assets to public/ |
brick:migrate {module} |
Run module migrations |
brick:rollback {module} |
Rollback module migrations |
brick:refresh {module} |
Refresh (rollback + re-run) module migrations |
brick:seed {module} |
Run module seeders |
Command Options
โ๏ธ Configuration Reference
Environment Variables
| Variable | Default | Description |
|---|---|---|
BRICK_BRIDGE_ENABLED |
true |
Enable/disable the bridge globally |
BRICK_BRIDGE_QUEUE |
default |
Queue for async bridge calls |
BRICK_BRIDGE_CACHE |
null |
Cache store for circuit breaker & async results |
BRICK_ASSETS_METHOD |
copy |
Asset publishing method (copy or symlink) |
BRICK_AUTO_ENABLE_DEPENDENCIES |
false |
Auto-enable missing dependencies |
๐ง Adding Custom Middleware
Create a middleware class:
Register in config/brick.php:
๐งฉ Module Dependencies
Declare dependencies in module.json:
When enabling:
โ Compatibility Notes
| Package | Notes |
|---|---|
| Spatie Media Library | Use HasMedia trait directly in module models |
| Laravel Socialite | Place OAuth controllers in Auth module's Http/Controllers/ |
| Laravel Passport | Register Passport in Auth module's service provider |
| Laravel Telescope | Automatically captures all bridge calls via logging middleware |
| Laravel Debugbar | No conflicts; bridge calls appear in the timeline |
| Laravel Octane | Fully safe โ no static state anywhere in the package |
๐ Package Structure
๐ค Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Write tests for your changes
- Run the test suite:
composer test - Submit a pull request
๐ License
The MIT License (MIT). See LICENSE for details.
"Each module is a brick. Stack them wisely." โ andrebhas/laravel-brick
All versions of laravel-brick with dependencies
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/console Version ^9.0|^10.0|^11.0|^12.0
illuminate/cache Version ^9.0|^10.0|^11.0|^12.0
illuminate/queue Version ^9.0|^10.0|^11.0|^12.0
illuminate/filesystem Version ^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0
illuminate/routing Version ^9.0|^10.0|^11.0|^12.0
illuminate/log Version ^9.0|^10.0|^11.0|^12.0