PHPackages                             monarul007/laravel-modular-system - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. monarul007/laravel-modular-system

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

monarul007/laravel-modular-system
=================================

WordPress-like modular system for Laravel with plug-and-play functionality

122PHP

Since Nov 25Pushed 5mo agoCompare

[ Source](https://github.com/Monarul007/laravel-modular-system)[ Packagist](https://packagist.org/packages/monarul007/laravel-modular-system)[ RSS](/packages/monarul007-laravel-modular-system/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Modular System
======================

[](#laravel-modular-system)

A Laravel package that provides **WordPress-like plug-and-play functionality** for managing modules dynamically. Upload, enable, disable, and manage modules through a web interface without touching code.

Features
--------

[](#features)

- 🔌 **Module Upload**: Drag-and-drop ZIP files to install modules
- ⚡ **Hot-swappable**: Enable/disable modules without restart
- 🎛️ **Admin Panel**: Vue.js interface for module management
- 📡 **API-First**: RESTful endpoints for SPA frontends
- 🛠️ **CLI Tools**: Artisan commands for developers
- 🗑️ **Module Removal**: Safely uninstall modules with confirmation
- 🎨 **View Resolution**: Automatic view namespace registration for modules
- 🏗️ **Component Generators**: Create controllers, models, migrations, and more
- 📦 **Asset Management**: Publish and manage module-specific assets
- ⚛️ **Inertia.js Support**: Full compatibility with Inertia.js for modern SPAs

Installation
------------

[](#installation)

```
composer require monarul007/laravel-modular-system
```

Setup
-----

[](#setup)

### 1. Publish Configuration &amp; Assets

[](#1-publish-configuration--assets)

The package now includes **smart template engine detection** that automatically publishes the appropriate view files (Blade, Inertia+Vue, or Inertia+React) based on your application setup.

```
# Detect your templating engine
php artisan modular:detect-engine

# Publish everything (views will be auto-detected)
php artisan vendor:publish --provider="Monarul007\LaravelModularSystem\ModularSystemServiceProvider"

# Or publish individually
php artisan vendor:publish --tag=modular-config
php artisan vendor:publish --tag=modular-routes
php artisan vendor:publish --tag=modular-views  # Auto-detects and publishes appropriate views

# Force specific view types
php artisan vendor:publish --tag=modular-views-blade    # Blade templates only
php artisan vendor:publish --tag=modular-views-inertia  # Inertia components only
```

See [VIEW-PUBLISHING.md](VIEW-PUBLISHING.md) for detailed information about smart view publishing.

### 2. Configure (Optional)

[](#2-configure-optional)

Edit `config/modular-system.php`:

```
return [
    'modules_path' => base_path('modules'),
    'cache_enabled' => true,
    'cache_ttl' => 3600,
    'upload_max_size' => 2048, // KB
];
```

Usage
-----

[](#usage)

### CLI Commands

[](#cli-commands)

#### Module Management

[](#module-management)

```
# List all modules
php artisan module:list

# Create new module (interactive with route alias setup)
php artisan make:module YourModule

# Create with custom alias
php artisan make:module YourModule --alias=custom-route

# Skip confirmation
php artisan make:module YourModule --skip-confirmation

# Enable module (interactive with route alias setup)
php artisan module:enable YourModule

# Enable with custom alias
php artisan module:enable YourModule --alias=custom-route

# Skip confirmation
php artisan module:enable YourModule --skip-confirmation

# Disable module
php artisan module:disable YourModule

# Remove/uninstall module (with confirmation)
php artisan module:remove YourModule

# Force remove (skip confirmation and delete assets)
php artisan module:remove YourModule --force

# Test module upload
php artisan test:module-upload module.zip
```

#### Component Generation

[](#component-generation)

```
# Create controller
php artisan module:make-controller Blog PostController
php artisan module:make-controller Blog PostController --api
php artisan module:make-controller Blog PostController --resource

# Create model
php artisan module:make-model Blog Post
php artisan module:make-model Blog Post --migration

# Create migration
php artisan module:make-migration Blog create_posts_table --create=posts
php artisan module:make-migration Blog add_status_to_posts --table=posts

# Create middleware
php artisan module:make-middleware Blog CheckBlogAccess

# Create command
php artisan module:make-command Blog PublishPostCommand
```

#### Asset Management

[](#asset-management)

```
# Publish module assets
php artisan module:publish Blog
php artisan module:publish --all

# Set or change module route alias
php artisan module:set-alias Blog
php artisan module:set-alias Blog new-alias
php artisan module:set-alias Blog custom-route --force
```

### API Endpoints

[](#api-endpoints)

```
# Module Management
GET    /api/v1/admin/modules              # List modules
POST   /api/v1/admin/modules/upload       # Upload module ZIP
POST   /api/v1/admin/modules/enable       # Enable module
POST   /api/v1/admin/modules/disable      # Disable module
POST   /api/v1/admin/modules/uninstall    # Uninstall module
GET    /api/v1/admin/modules/download/{name}  # Download module

```

For detailed API documentation with request/response examples, see [API.md](API.md).

### Web Interface

[](#web-interface)

```
# Admin Panel
http://your-app.test/admin/modules
```

### Programmatic Usage

[](#programmatic-usage)

```
use Monarul007\LaravelModularSystem\Facades\ModuleManager;
use Monarul007\LaravelModularSystem\Facades\ModuleView;

// Module Management
$modules = ModuleManager::getAllModules();
ModuleManager::enableModule('YourModule');
ModuleManager::disableModule('YourModule');
ModuleManager::uninstallModule('YourModule');

// View & Asset Management
$viewPath = ModuleView::view('Blog', 'index'); // Returns: 'blog::index'
$assetUrl = ModuleView::asset('Blog', 'app.js');
$exists = ModuleView::viewExists('Blog', 'custom-template');
ModuleView::publishAssets('Blog');
```

Creating Modules
----------------

[](#creating-modules)

### 1. Generate Module

[](#1-generate-module)

```
php artisan make:module YourModule
```

### 2. Module Structure

[](#2-module-structure)

```
modules/YourModule/
├── module.json                      # Module configuration
├── Providers/ServiceProvider.php    # Laravel service provider
├── Console/Commands/                # Artisan commands
├── Http/
│   ├── Controllers/                 # Controllers
│   └── Middleware/                  # Middleware
├── Models/                          # Eloquent models
├── Database/migrations/             # Database migrations
├── routes/
│   ├── api.php                      # API routes
│   └── web.php                      # Web routes
├── resources/
│   ├── views/                       # Blade templates
│   └── js/                          # Frontend assets
├── config/YourModule.php            # Module configuration
└── README.md                        # Module documentation

```

### 3. Module Configuration (module.json)

[](#3-module-configuration-modulejson)

```
{
    "name": "YourModule",
    "description": "Your module description",
    "version": "1.0.0",
    "namespace": "Modules\\YourModule",
    "providers": [
        "Modules\\YourModule\\Providers\\YourModuleServiceProvider"
    ],
    "dependencies": []
}
```

### 4. Using Module Views

[](#4-using-module-views)

In your module's controller:

```
namespace Modules\Blog\Http\Controllers;

use Illuminate\Routing\Controller;

class PostController extends Controller
{
    public function index()
    {
        // Views are automatically namespaced with lowercase module name
        return view('blog::index');
    }

    public function show($id)
    {
        $post = Post::findOrFail($id);
        return view('blog::show', compact('post'));
    }
}
```

In your Blade templates:

```
{{-- Extend module layout --}}
@extends('blog::layouts.app')

{{-- Include module partials --}}
@include('blog::partials.header')

{{-- Use module assets --}}

```

### 5. Package &amp; Distribute

[](#5-package--distribute)

```
zip -r YourModule.zip modules/YourModule/
```

Configuration
-------------

[](#configuration)

### Module Path

[](#module-path)

By default, modules are stored in `base_path('modules')`. Change this in config:

```
'modules_path' => base_path('custom-modules'),
```

### Cache Configuration

[](#cache-configuration)

```
'cache_enabled' => true,
'cache_ttl' => 3600, // seconds
```

### Upload Limits

[](#upload-limits)

```
'upload_max_size' => 2048, // KB
'allowed_extensions' => ['zip'],
```

Security
--------

[](#security)

- File validation (ZIP only)
- Module structure validation
- Automatic cleanup on failures
- Size limits on uploads

Complete Example: Building a Blog Module
----------------------------------------

[](#complete-example-building-a-blog-module)

```
# 1. Create module
php artisan make:module Blog

# 2. Generate components
php artisan module:make-model Blog Post --migration
php artisan module:make-model Blog Category --migration
php artisan module:make-controller Blog PostController --resource
php artisan module:make-controller Blog Api/PostController --api
php artisan module:make-middleware Blog CheckPostOwnership

# 3. Enable and setup
php artisan module:enable Blog
php artisan module:publish Blog
```

**Controller Example** (`modules/Blog/Http/Controllers/PostController.php`):

```
namespace Modules\Blog\Http\Controllers;

use Illuminate\Routing\Controller;
use Modules\Blog\Models\Post;

class PostController extends Controller
{
    public function index()
    {
        $posts = Post::latest()->paginate(10);
        return view('blog::index', compact('posts'));
    }

    public function show($slug)
    {
        $post = Post::where('slug', $slug)->firstOrFail();
        return view('blog::show', compact('post'));
    }
}
```

**View Example** (`modules/Blog/resources/views/index.blade.php`):

```
@extends('blog::layouts.app')

@section('content')
    Blog Posts
    @foreach($posts as $post)

            {{ $post->title }}
            {{ $post->excerpt }}
            Read More

    @endforeach
@endsection
```

**Routes Example** (`modules/Blog/routes/web.php`):

```
use Illuminate\Support\Facades\Route;
use Modules\Blog\Http\Controllers\PostController;

Route::prefix('blog')->name('blog.')->group(function () {
    Route::get('/', [PostController::class, 'index'])->name('index');
    Route::get('/{slug}', [PostController::class, 'show'])->name('show');
});
```

Interactive Features
--------------------

[](#interactive-features)

### Module Creation with Route Alias

[](#module-creation-with-route-alias)

When creating a module, you'll be prompted to:

1. Confirm module creation
2. Choose a route alias (suggested: kebab-case version of module name)
3. Enter custom alias or use suggested one

```
php artisan make:module BlogSystem

# Output:
# Creating new module: BlogSystem
# Do you want to create this module? (yes/no) [yes]: yes
#
# Route Alias Configuration
# Module: BlogSystem
# Suggested alias: blog-system
# Choose route alias option:
#   [use_suggested] Use suggested (blog-system)
#   [custom      ] Enter custom alias
#   [skip        ] Skip (use default)
```

### Module Enable with Confirmation

[](#module-enable-with-confirmation)

Enabling a module now shows module information and asks for confirmation:

```
php artisan module:enable Blog

# Output:
# Module: Blog
# Description: The Blog module
# Do you want to enable this module? (yes/no) [yes]:
```

### Module Removal with Asset Cleanup

[](#module-removal-with-asset-cleanup)

Removing a module asks about published assets:

```
php artisan module:remove Blog

# Output:
# Are you sure you want to remove module 'Blog'? (yes/no) [no]: yes
# Removing module 'Blog'...
# Do you want to delete published assets for this module? (yes/no) [yes]:
```

### Change Module Route Alias

[](#change-module-route-alias)

Update the route alias for an existing module:

```
php artisan module:set-alias Blog

# Output:
# Module: Blog
# Current alias: blog
#
# Route Alias Configuration
# Suggested alias: blog
# Choose route alias option:
#   [suggested] Use suggested (blog)
#   [custom   ] Enter custom alias
#   [remove   ] Remove alias (use default)
#   [cancel   ] Cancel
```

You can also specify the alias directly:

```
# Set specific alias
php artisan module:set-alias Blog blog-posts

# Force update without confirmation
php artisan module:set-alias Blog articles --force
```

Advanced Features
-----------------

[](#advanced-features)

### View Helpers

[](#view-helpers)

```
use Monarul007\LaravelModularSystem\Facades\ModuleView;

// Check if view exists
if (ModuleView::viewExists('Blog', 'custom-template')) {
    return view('blog::custom-template');
}

// Get all module views
$views = ModuleView::getModuleViews('Blog');

// Get asset URL
$jsUrl = ModuleView::asset('Blog', 'app.js');
```

### Middleware Registration

[](#middleware-registration)

In your module's service provider:

```
use Illuminate\Routing\Router;

public function boot(): void
{
    $router = $this->app->make(Router::class);
    $router->aliasMiddleware('check-blog-access',
        \Modules\Blog\Http\Middleware\CheckBlogAccess::class
    );
}
```

### Custom Commands

[](#custom-commands)

Register in your module's service provider:

```
public function boot(): void
{
    if ($this->app->runningInConsole()) {
        $this->commands([
            \Modules\Blog\Console\Commands\PublishPostCommand::class,
        ]);
    }
}
```

Troubleshooting
---------------

[](#troubleshooting)

### Module Not Found

[](#module-not-found)

```
# Verify module.json exists
ls modules/YourModule/module.json

# Clear cache
php artisan cache:clear
```

### Views Not Loading

[](#views-not-loading)

```
# Ensure module is enabled
php artisan module:enable YourModule

# Clear view cache
php artisan view:clear
```

### Assets Not Loading

[](#assets-not-loading)

```
# Publish assets
php artisan module:publish YourModule

# Check permissions
chmod -R 755 public/modules/
```

API Reference
-------------

[](#api-reference)

### ModuleManager Facade

[](#modulemanager-facade)

```
ModuleManager::getAllModules()              // Get all modules
ModuleManager::getEnabledModules()          // Get enabled modules
ModuleManager::enableModule($name)          // Enable a module
ModuleManager::disableModule($name)         // Disable a module
ModuleManager::uninstallModule($name)       // Uninstall a module
ModuleManager::moduleExists($name)          // Check if module exists
ModuleManager::isModuleEnabled($name)       // Check if enabled
ModuleManager::getModuleConfig($name)       // Get module config
```

### ModuleView Facade

[](#moduleview-facade)

```
ModuleView::view($module, $view)            // Get view path
ModuleView::asset($module, $asset)          // Get asset URL
ModuleView::viewExists($module, $view)      // Check if view exists
ModuleView::getModuleViews($module)         // Get all module views
ModuleView::publicPath($module)             // Get public path
ModuleView::publishAssets($module)          // Publish assets
```

Command Options
---------------

[](#command-options)

### Module Creation Options

[](#module-creation-options)

```
# Interactive with all prompts
php artisan make:module Blog

# Skip confirmation
php artisan make:module Blog --skip-confirmation

# Set custom alias
php artisan make:module Blog --alias=articles

# Both options
php artisan make:module Blog --skip-confirmation --alias=blog-posts
```

### Module Enable Options

[](#module-enable-options)

```
# Interactive with confirmation
php artisan module:enable Blog

# Skip confirmation
php artisan module:enable Blog --skip-confirmation

# Set custom alias during enable
php artisan module:enable Blog --alias=blog-posts
```

### Module Remove Options

[](#module-remove-options)

```
# Interactive with confirmation and asset cleanup prompt
php artisan module:remove Blog

# Force remove (skip all prompts, delete everything)
php artisan module:remove Blog --force
```

### Route Alias Management

[](#route-alias-management)

```
# Interactive alias change
php artisan module:set-alias Blog

# Set specific alias
php artisan module:set-alias Blog articles

# Force update without prompts
php artisan module:set-alias Blog blog-posts --force
```

Testing &amp; Examples
----------------------

[](#testing--examples)

For comprehensive testing workflows and real-world examples, see [TESTING-EXAMPLES.md](TESTING-EXAMPLES.md).

Smart View Publishing
---------------------

[](#smart-view-publishing)

The package automatically detects your application's templating engine and publishes the appropriate view files:

- **Blade Templates** - Traditional Laravel views with Tailwind CSS
- **Inertia.js + Vue** - Vue 3 components with Composition API
- **Inertia.js + React** - React components with Hooks

```
# Detect your setup
php artisan modular:detect-engine

# Publish appropriate views automatically
php artisan vendor:publish --tag=modular-views
```

**Available Views:**

- Admin Dashboard
- Module Management (upload, enable, disable, uninstall)
- Responsive layouts with Tailwind CSS

See [VIEW-PUBLISHING.md](VIEW-PUBLISHING.md) for complete documentation.

Inertia.js Integration
----------------------

[](#inertiajs-integration)

Full Inertia.js support for building modern SPAs with your modules.

**Important:** If you're using Inertia, make sure flash messages are properly configured. See [INERTIA-SETUP.md](INERTIA-SETUP.md) for setup instructions.

**Quick Start:**

```
// Return Inertia response from module
return module_inertia('Blog', 'Posts/Index', ['posts' => $posts]);

// Return Blade view with Inertia support
return module_view('blog', 'welcome', ['title' => 'Welcome']);
```

**Documentation:**

- [INERTIA-SETUP.md](INERTIA-SETUP.md) - Setup and troubleshooting
- [INERTIA-GUIDE.md](INERTIA-GUIDE.md) - Complete integration guide
- [INERTIA-QUICK-REFERENCE.md](INERTIA-QUICK-REFERENCE.md) - Quick reference

Architecture
------------

[](#architecture)

For detailed system architecture, component interactions, and technical implementation details, see [ARCHITECTURE.md](ARCHITECTURE.md).

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for version history.

License
-------

[](#license)

MIT License

Support
-------

[](#support)

For issues, questions, or contributions, please visit the GitHub repository.

Credits
-------

[](#credits)

Created for Laravel applications requiring dynamic module management.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance48

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f57580b3c00811802fb14d9cf07a5500482e0dc3aaff6efea1ff14578e01204e?d=identicon)[monarul007](/maintainers/monarul007)

### Embed Badge

![Health badge](/badges/monarul007-laravel-modular-system/health.svg)

```
[![Health](https://phpackages.com/badges/monarul007-laravel-modular-system/health.svg)](https://phpackages.com/packages/monarul007-laravel-modular-system)
```

###  Alternatives

[dm/ajaxcom

Controls Ajax from PHP

1816.4k](/packages/dm-ajaxcom)[slack/hack-json-schema

Hack JSON Schema generator

302.4k](/packages/slack-hack-json-schema)[proai/lumen-annotations

Route and event binding annotations for Laravel Lumen

1012.4k](/packages/proai-lumen-annotations)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
