PHPackages                             lucidnetworks/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. [Framework](/categories/framework)
4. /
5. lucidnetworks/laravel-modular

ActiveLibrary[Framework](/categories/framework)

lucidnetworks/laravel-modular
=============================

Modular pattern generator for Laravel 5

1.0.1-beta(9y ago)010MITPHPPHP &gt;=5.4.0

Since Sep 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/rudignet/Laravel-Modular)[ Packagist](https://packagist.org/packages/lucidnetworks/laravel-modular)[ Docs](https://github.com/rudignet/Laravel-Modular)[ RSS](/packages/lucidnetworks-laravel-modular/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (2)Used By (0)

Laravel-Modular
===============

[](#laravel-modular)

Structure to use laravel as modular system

To install this app:
--------------------

[](#to-install-this-app)

1. Include `"lucidnetworks/laravel-modular": "^1.0"` on your require composer.json
2. Add `Lucid\Modular\ModulesServiceProvider::class` to your config/app providers array
3. Run `php artisan vendor:publish`
4. Run `php artisan migrate`

\###Modules activation or desactivation To activate or desactivate a module just insert your moduleName on \_modules array into your modules config file

\####Environement configuration You can specify in your .env file another config file for modules using the key `MODULES_CONFIG_FILE` Ex: Use `MODULES_CONFIG_FILE=modules_my_site` tu use file modules\_my\_site as configuration file, you can otherwise use `MODULES_CONFIG_FILE=my_config.modules` to specify an array inside my\_config file

\#Create New Module:

1. Create your module structure with `php artisan modules:new ModuleName`
2. Add your module name into \_modules inside modules.php or your specific modules configuration file

\##Modules structure

- boot.php =&gt; I'ts loaded when module its instanciated, place here your module routes, hooks, at any thing we enat to load on module boot
- config.php =&gt; Module configuration file, this config will be loadable with `config('{module_name}.{key}')`
- views/ =&gt; Module views, these views will be loadable with `view("{module_name}::{view}")` these views are overloadable
- lang/ =&gt; Module translations, this translations will be loadable with `trans("{module_name}::{key}")` (Use one subfolder for each language, as usual)
- assets/ =&gt; Module public files, this files will be into this public url {your\_laravel\_url}/modules/{moduleName}/{path\_inside\_assets\_folder}
- migrations/ =&gt; Module migrations, see migrations section to know how to do
- tests/ =&gt; Module test, see tests section to know how to do

\##Module routing: Module routes must be declarated on boot.php, remember you must to use complete namespaces on all methods called into routes or use the namespace property To use routes with parameters use route key `'params_closure' => function(){}` who receives a closure that returns all params nedded to create the route

Route sample: `Route::group(['middleware' => ['web','auth'], 'as'=>'admin::', 'namespace' => 'Modules\Admin\Controllers',  'params_closure' => function(){ return ['id' => 23]; }], function() { /* route code */ });`

\##Hooks: Hooks allow to register funtions that can be called from your app views To add a hook use `ModulesManager::attachHook(string Point, string Name, callable Closure)` normally hooks must be added into boot.php

**\[Parameters\]:**

- Point: Attach point where the hook will be assigned
- Name: Internal unique name for the hook, use always {module\_name}::{hook\_name} as name. Ex MyModule::MyHook
- Closure: This closure must return an string that will be concatenated with all other hooks attached to the same point when `ModulesManager::getHook({attach_point})` was called

\###Hooks ordenation: Each time `ModulesManager::attachHook` was called, hook will be saved into database, that's allow to order hook depending your preferences, if you don't set an order all hooks will be ordered between his insertion into database

Hook Example: `ModulesManager::attachHook('admin.actionBar','MyModule::HookAction1', function(){ return 'TEST-HOOK'; });`

\###Hooks use: To get your registered hooks content use `ModulesManager::getHook({attach_point})` this will return all html returned by all hooks was registered to this attach\_point

\##Module public methods registration This tool allow you to register a method that can be called as a hook, but in this case it can returns any kind of result, that allow you to set any method of your module public To register a method as public use `ModulesManager::registerModuleFunc(string Name, callable Closure);`

**\[Parameters\]:**

- Name: Public unique name for the function, use always {module\_name}::{function\_name} as name. Ex MyModule::MyFunction
- Closure: Function will receive an array of params and return any kind of result, Ex: function($params){ /\* some code \*/ }

\###Calling a module public method After register a method on your module you can access it from anywhere using `ModulesManager::callModuleFunc(string Name, array Params = [], Default = null)` or `callModuleFuncOrFail` with same signature if you want to generate an exception if {method\_name} has not been registered

**\[Parameters\]:**

- Name: Public unique name for the function, use always {module\_name}::{function\_name} as name. Ex MyModule::MyFunction
- Params: Array of parameters for the method, will be receibed by the closure
- Default: Value will be returned if Name has not been registered

`callModuleFuncOrFail(string Name, array Params = [],string Message = '')` will generate an exception if Name has not been registered, in this case Message it's the message will be show by the generated exception. Ex 'You must to install x module'

\##Assets: Each module can have his own public files, to create public content just put ir into your module assets folder, this content will be putted into the next public url {your\_laravel\_base\_url}/modules/{moduleName}/{path\_to\_your\_file\_from\_assets}

For security reasons ../ is not allowed into paths

\#ModulesManager utilities:

\##Application messages: You can register application messages with the method `ModulesManager::displayHeaderMessage(string $message, string $type = 'danger', string $title = '', bool $dismissible = true, string $icon = '') `before you can get your messages at any time with `ModulesManager::getHeaderMessages()` As an example you can register your module error messages and use getHeaderMessages to whow them into your app

\##Static arrays ::css y ::js This two static arrays of ModulesManager allow you to inject some css and js filenames from your modules, Ex: `ModulesManager::js[] = '/modules/MyModule/js/test.js'`

After this you can get all filenames accessing `ModulesManager::js` or `ModulesManager::css` wherever you need, as an example you can use this arrays into your header template to load all files needed by your modules

Remember that if you want to use a file from your module assets folder you must to use his public path /modules/{moduleName}/{path\_to\_your\_file\_from\_assets}

\##Migrations To execute your module migrations run `artisan modules:migrate ModuleName`

If you want to rollback a migration use `artisan modules:migrate ModuleName --down`

If your modules configuration file is different than modules.php you must specify your config file or config key like this `artisan modules:migrate ModuleName YourConfigFile` or `artisan modules:migrate ModuleName YourConfigFile --down`

\#Tests To execute your module tests run `artisan modules:test ModuleName` or just `artisan modules:test` if you want to run all activated modules tests.

If your modules configuration file is different than modules.php you must specify your config file or config key like this `artisan modules:test ModuleName YourConfigFile` or `artisan modules:test all YourConfigFile` for all tests

Remember all test will be runned as if it's into your laravel test folder and not into your module test folder, then all test must to extend from TestBase without any namespace

\#Artisan commands You can add your module artisan commands easily, just add into \_commands array inside your module config.php file the className for your command. Ex: `'_commands' => ['App\Modules\MyModule\commands\testCommand']`

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3578d ago

### Community

Maintainers

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

---

Top Contributors

[![rudignet](https://avatars.githubusercontent.com/u/2227935?v=4)](https://github.com/rudignet "rudignet (61 commits)")

---

Tags

laravelgeneratorartisanmodulemodulesstructurepatternmodularArtemSchanderl5modular

### Embed Badge

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

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

###  Alternatives

[artem-schander/l5-modular

Modular pattern generator for Laravel

217239.7k](/packages/artem-schander-l5-modular)[internachi/modular

Modularize your Laravel apps

1.2k786.8k13](/packages/internachi-modular)[mhmiton/laravel-modules-livewire

Using Laravel Livewire in Laravel Modules package with automatically registered livewire components for every modules.

234455.5k9](/packages/mhmiton-laravel-modules-livewire)[pingpong/modules

Laravel Modules

576190.1k13](/packages/pingpong-modules)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21313.7k3](/packages/ecotone-laravel)[rcv/core

Enterprise-Grade Modular Architecture for Laravel Applications - A powerful Laravel package that revolutionizes application development with robust Service Repository Pattern, Dynamic Module Management, and 50+ Artisan commands for scalable, maintainable applications.

131.2k](/packages/rcv-core)

PHPackages © 2026

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