Loom Modules π§©
Loom is modular by design.
Each module is a self-contained feature that can be enabled, disabled, or customized without affecting the rest of the application.
What is a Module?
Section titled βWhat is a Module?βA module is a package of features that can include:
- Routes
- Controllers
- Policies
- Views / Components
- Migrations / Seeders
- Config files
- Event listeners / Notifications
Modules allow you to pick only what you need for your application.
Feature Flags
Section titled βFeature FlagsβLoom uses Laravel Pennant for feature flags.
Enable or disable a module in config/loom.php
:
return [ 'modules' => [ 'blog' => true, 'shop' => false, 'newsletter' => true, ],];
Or programmatically:
use Laravel\Pennant\Feature;
if (Feature::active('blog')) { // Module code will run}
Adding a Module
Section titled βAdding a ModuleβUse the CLI to add a module:
php artisan loom:add blog
- Publishes routes, controllers, views, and seeders
- Automatically enables the module if feature flag is active
- Updates module list (
loom:list
)
Removing / Disabling a Module
Section titled βRemoving / Disabling a ModuleβDisable a module via feature flag:
Feature::off('shop');
Remove a module entirely (optional):
php artisan loom:remove shop
- Removes routes, controllers, and views
- Leaves database tables if needed (can run
loom:reset
for full cleanup)
Module Structure
Section titled βModule StructureβA typical module has the following layout:
Modules/ ββ Blog/ β ββ Http/ β β ββ Controllers/ β ββ Models/ β ββ Views/ β ββ database/ β β ββ migrations/ β β ββ seeders/ β ββ config.php ββ Shop/ ββ ...
- Http/Controllers β module routes and business logic
- Models β module-specific models
- Views β Livewire components / Blade templates
- Database β migrations & seeders
- Config β module-specific configuration
Extending Modules
Section titled βExtending ModulesβYou can:
- Override resources (Models, Policies, Views)
- Add your own seeders or migrations
- Create custom commands for the module
- Trigger events / notifications from the module
Next Steps
Section titled βNext Stepsβ- Add your first module β
/tutorials/add-blog-module/
- Learn about Core architecture β
/guides/core-package/
- Check CLI commands β
/reference/commands/