This guide walks you through creating your first module, understanding its structure, and building a simple feature using Laravel Modular.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/internachi/modular/llms.txt
Use this file to discover all available pages before exploring further.
Before starting, make sure you’ve installed Laravel Modular and optionally configured your namespace.
Create Your First Module
Let’s create a “blog” module to demonstrate the workflow:Generate the module
Run the You’ll see output showing the files being created:
make:module command with your desired module name:Update Composer dependencies
Laravel Modular automatically adds your module to your application’s This registers the module’s autoloader and makes it available to your application.
composer.json. Now install it:Understanding Module Structure
Let’s explore what was created:Module composer.json
Each module has its owncomposer.json that defines its namespace and dependencies:
app-modules/blog/composer.json
Service Provider
Every module includes a service provider for registering services:app-modules/blog/src/Providers/BlogServiceProvider.php
Building a Feature
Let’s build a simple blog post feature using Laravel’smake: commands with the --module option.
Create a model
Generate a The
Post model in the blog module:-m flag creates a migration alongside the model.This creates:app-modules/blog/src/Models/Post.phpapp-modules/blog/database/migrations/YYYY_MM_DD_HHMMSS_create_posts_table.php
Create a controller
Generate a resource controller:This creates
app-modules/blog/src/Http/Controllers/PostController.php with all resource methods (index, create, store, show, edit, update, destroy).Create a view component
Generate a Blade component for displaying posts:This creates:
app-modules/blog/src/View/Components/PostCard.phpapp-modules/blog/resources/views/components/post-card.blade.php
Add routes
Edit
app-modules/blog/routes/blog-routes.php to add your routes:app-modules/blog/routes/blog-routes.php
Using Module Features
Now that you’ve built some components, here’s how to use them:Available Make Commands
All Laravelmake: commands support the --module option:
Model & Database
Model & Database
Controllers & HTTP
Controllers & HTTP
Views & Components
Views & Components
Business Logic
Business Logic
Authorization & Validation
Authorization & Validation
Console & Services
Console & Services
Testing
Testing
Seeding Module Data
You can run seeders specific to your module:Module Management Commands
Laravel Modular provides several utility commands:Next Steps
Now that you’ve created your first module, explore more advanced features:Namespace Configuration
Learn about advanced configuration options and customization
Module Components
Deep dive into module-namespaced Blade components
Module Views
Working with Blade templates and module namespaces
Plugin System
Understand the extensible plugin architecture