PHPackages                             mehediishere/laravel-modular - 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. mehediishere/laravel-modular

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

mehediishere/laravel-modular
============================

Native zero-dependency modular architecture for Laravel ERP systems. Provides module discovery, sidebar management, and artisan scaffolding.

v1.0.3(1mo ago)06MITPHPPHP ^8.2

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/mehediishere/laravel-modular)[ Packagist](https://packagist.org/packages/mehediishere/laravel-modular)[ Docs](https://github.com/mehediishere/laravel-modular)[ RSS](/packages/mehediishere-laravel-modular/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (5)Used By (0)

mehediishere/laravel-modular
============================

[](#mehediisherelaravel-modular)

A native, zero-dependency modular architecture package for Laravel Modular systems.

No magic traits. No JSON state files. Just pure Laravel.

---

Features
--------

[](#features)

- **Module discovery** — enable/disable modules from a single config file
- **Zero dependencies** — built entirely on Laravel's own service container, routing, and filesystem
- **Sidebar management with group merging** — modules declare a `group_id`; any modules sharing the same `group_id` are automatically merged into one dropdown in the admin panel
- **Permission-filtered sidebar** — items invisible to the current user are stripped before rendering
- **Artisan scaffolding** — `php artisan module:make POS` generates the full folder structure with stubs
- **Publishable stubs** — customise the scaffolding output to match your team's conventions
- **Per-module config, migrations, views, routes, translations, and commands** — all self-registering
- **Sidebar caching** — per-user cache with configurable TTL
- **Laravel auto-discovery** — no manual provider registration needed

---

Requirements
------------

[](#requirements)

DependencyVersionPHP^8.2Laravel^11.0---

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

[](#installation)

```
composer require mehediishere/laravel-modular
```

Laravel's package auto-discovery registers the service provider automatically.

Publish the config files:

```
php artisan vendor:publish --tag=modular-config
```

This creates two files in your project:

- `config/modular.php` — package settings (sidebar cache, TTL)
- `config/modules.php` — your enabled modules list and base path

Add the `Modules` namespace to your project's `composer.json`:

```
"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Modules\\": "Modules/"
    }
}
```

Then run `composer dump-autoload`.

---

Quick start
-----------

[](#quick-start)

### 1. Scaffold a module

[](#1-scaffold-a-module)

```
php artisan module:make POS
php artisan module:make Ecommerce
php artisan module:make Account
php artisan module:make Payroll
```

Each command creates a full module folder at `Modules/{Name}/`:

```
Modules/POS/
├── app/
│   ├── Http/Controllers/
│   ├── Http/Requests/
│   ├── Models/
│   ├── Services/
│   ├── Contracts/
│   ├── Providers/
│   │   └── POSServiceProvider.php
│   ├── Console/Commands/
│   ├── Events/
│   └── Listeners/
├── config/
│   ├── config.php
│   └── sidebar.php           ← define group_id here
├── database/
│   ├── migrations/
│   ├── seeders/
│   └── factories/
├── resources/views/
├── resources/lang/en/
├── routes/
│   ├── web.php
│   └── api.php
└── tests/
    ├── Feature/
    ├── Unit/
    └── TestCase.php

```

### 2. Enable the module

[](#2-enable-the-module)

Open `config/modules.php` and add your module:

```
'enabled' => [
    'POS',
    'Ecommerce',
    'Account',
    'Payroll',
],
```

### 3. Autoload and migrate

[](#3-autoload-and-migrate)

```
composer dump-autoload
php artisan migrate
```

---

Sidebar management
------------------

[](#sidebar-management)

### The `group_id` concept

[](#the-group_id-concept)

The sidebar is built from each module's `config/sidebar.php`. The key field is `group_id` — a short snake\_case string that identifies which dropdown group this module's items belong to.

**Modules with the same `group_id` are merged into one dropdown.**

This means you can have `Account` and `Payroll` as separate modules but group them both under a single "Finance" dropdown in the sidebar — neither module needs to know about the other.

```
Account module           Payroll module
group_id: 'finance'  +  group_id: 'finance'
─────────────────────────────────────────────
                 Merged result
                 ▼ Finance            ← one dropdown
                   Chart of Accounts  ← from Account
                   Journal Entries    ← from Account
                   Payroll Runs       ← from Payroll
                   Tax Reports        ← from Payroll

```

### Sidebar config schema

[](#sidebar-config-schema)

```
