PHPackages                             mnabialek/laravel-simple-modules - 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. mnabialek/laravel-simple-modules

ActiveLibrary[Framework](/categories/framework)

mnabialek/laravel-simple-modules
================================

Allows creating Laravel modules for better project structure

v0.2.6(9y ago)211034MITPHP

Since Apr 21Pushed 9y ago6 watchersCompare

[ Source](https://github.com/mnabialek/laravel-modular)[ Packagist](https://packagist.org/packages/mnabialek/laravel-simple-modules)[ RSS](/packages/mnabialek-laravel-simple-modules/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (5)Versions (15)Used By (0)

Laravel Modular
---------------

[](#laravel-modular)

[![Build Status](https://camo.githubusercontent.com/83da62b85432a64e6604e180a7f8884ab56385248bfc4ca46a0b6c6799e5d402/68747470733a2f2f7472617669732d63692e6f72672f6d6e616269616c656b2f6c61726176656c2d6d6f64756c61722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mnabialek/laravel-modular)[![Coverage Status](https://camo.githubusercontent.com/e6265dff117d7c037b3a1f23810b2890e372d7dc88aa133ee4349526d3a75afb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d6e616269616c656b2f6c61726176656c2d6d6f64756c61722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mnabialek/laravel-modular?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a0e6df2543fcb1ce9ad862e402766bb308a6a860ba733801995dd1cc170ff16a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6e616269616c656b2f6c61726176656c2d6d6f64756c61722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mnabialek/laravel-modular/?branch=master)[![StyleCI](https://camo.githubusercontent.com/78a34188340e0b3ff9e2db698707e38aa00aa542fd32682c35ce9b0c2a2d6b23/68747470733a2f2f7374796c6563692e696f2f7265706f732f34383935323536392f736869656c64)](https://styleci.io/repos/48952569)

This module makes managing your Laravel 5 application much more easier. No more putting dozens or hundreds of files into single directory.

Now you can create for your Laravel 5 application multiple modules and each of them will have its own structure (in the way you decide).

### Supported version

[](#supported-version)

To install in Laravel **5.3+** use this branch, however to install in Laravel &lt; 5.3 please refer to **[version 0.1](https://github.com/mnabialek/laravel-modular/tree/0.1)**.

### Installation

[](#installation)

1. For Laravel 5.3+ run

    ```
    composer require mnabialek/laravel-modular 0.2.*
    ```

    in console to install this module.
2. Open `config/app.php` and:

    - Add

        ```
         Mnabialek\LaravelModular\Providers\ModularServiceProvider::class,
        ```

        in same section (`providers`)
    - Add

        ```
        'Modular' => Mnabialek\LaravelModular\Facades\Modular::class,
        ```

        into `aliases` section
3. Run

    ```
    php artisan vendor:publish --provider="Mnabialek\LaravelModular\Providers\ModularServiceProvider"
    ```

    in your console to publish default configuration files, sample app files (published in `app/Core`) and sample stubs files
4. In default seeder `database/seeds/DatabaseSeeder` at the end of `run` method add:

    ```
     Modular::seed($this);
    ```
5. In `app/Providers/RouteServiceProvider.php` at the end of `map` function add

    ```
    \Modular::loadRoutes($this->app['router'], 'web');
    \Modular::loadRoutes($this->app['router'], 'api');
    ```
6. In `database/factories/ModelFactory.php` (this step applies only to Laravel 5.1+) add at the end of file:

    ```
    Modular::loadFactories($factory);
    ```

### Getting started

[](#getting-started)

To get started run:

```
php artisan module:make TestModule
```

This command will create your `TestModule` module structure. Open directory and look at its structure. As you see some files uses `app/Core` abstract classes (those file where created during installation).

First decide, whether you want to use `app/Core` files or not. If not, you can remove this directory. Go to `resources/stubs/modular` and look at sample stubs. You can now alter them depending on your needs (you can remove all usages of `app/Core` files`, create new stubs etc.

Now open `config/modular.php` file, go to `stubs_groups` section and adjust `default` structure - you can specify here what `directories` and `files` should be created for default modules. When you finish, run:

```
php artisan module:make TestModule2
```

Now this new module will be created according to your needs. Great - you created your first module as you wanted!

### Customization

[](#customization)

This module is highly customizable. The concept is based on using group stubs and in each group you can define which directories should be created and which files should be created (you can omit directories if you want when in those directories you want to place files - they will be automatically created).

You can create multiple stubs groups, you can configure many things. Just go to `config/modular.php` and look at sample settings and comments in this file - if you want to change them, just do it, generate new sample module (or files) and see what will happen.

For all stubs groups the following replacements will be done for filename and file content (assuming you haven't changed default `{` and `}` separators to custom ones):

- `{module}` - this will be changed into module name
- `{class}` - this will be changed into used name of module/submodule/file
- `{moduleNamespace}` - this will be changed into module namespace
- `{namespace}` - this will be changed into main namespace of modules directory
- `{plural|lower}` - this will be changed into plural name of module (lowercase)

#### Routing customization

[](#routing-customization)

By default for each module you can load 2 routing files - `web.php` and `api.php` if you followed installation instructions. However, you might also decide to use single routing file for each module. In this case use

```
\Modular::loadRoutes($this->app['router']);

```

only in step 5 of installation.

You can also decide to put the whole routing files in groups as defaults in Laravel 5.3. In this case you can do it also in `RouteServiceProvider` - in such case please remember to alter your routes stubs to not apply same middleware twice because it will cause unexpected issues in your Laravel application.

### Available commands

[](#available-commands)

#### module:make

[](#modulemake)

This command creates new modules. You can create one module or multiple modules at once.

Example usage:

```
php artisan module:make Product Order
```

You can control what is created when running this command in `config/modular.php` in `stubs_groups` section. You can pass optional stub group name using `--group=test` in case you want to use multiple types of modules.

#### module:files

[](#modulefiles)

Allow to create files in module that already exists.

Example usage:

```
php artisan module:make Product Camera Radio
```

You can control what is created when running this command in `config/simplemodules.php` in `stubs_groups` section. You can pass optional stub group name using `--group=test`.

By default it creates "submodule" in existing module.

#### module:create-migration

[](#modulecreate-migration)

Creates migration file in given module

Example usage:

```
php artisan module:make-migration Product create_products_table
```

You can also use optional `--type` and `--table` options to set table and type of migration (you can of course create own types if you want) in order to create migration with template for given type, for example:

```
php artisan module:make-migration Product create_camera_table --table=cameras --type=create
```

it will create migration that is of type `create` - so in `up` method there will be creating `cameras` table and in `down` method deleting `cameras` table

#### module:seed

[](#moduleseed)

Runs main seeder for given modules. You need to remember that only main seeder will be launched. In case you have multiple seeders in single module, you should manually run extra seeders in main module seeder.

Example usage:

```
php artisan module:seed Product Order
```

#### migrate

[](#migrate)

This module register modules paths so when you run default Laravel `migrate` command all migrations will be run (both general and for all active modules)

Example usage:

```
php artisan migrate
```

#### db:seed

[](#dbseed)

If you done all steps in `Installation` section when you run `db:seed` command all main seeds from active modules will be run

Example usage:

```
php artisan db:seed
```

### Optimization

[](#optimization)

By default (you can customize it in config file), all modules are created with 2 options - `active` and `routes` - by default they are both set to `true`. The general rule for all modules options is like this - if option is set for module in configuration file, it will be used, otherwise some extra checks will be made to calculate. It does not apply to `active` option - in case it's missing it's assumed to be `true`.

Available options for modules:

- `active` - whether module is active
- `provider` - whether module has service provider
- `factory` - whether module has model factory
- `routes` - whether module has `routes.php` file
- `seeder` - whether module has seeder file

In addition to use custom routing files, you can use also additional settings:

- `api_routes` - whether module has `api.php` routing file
- `web_routes` - whether module has `web.php` routing file

Prefix of option should match the name of routing file, if you would like additional `extra.php` routing file, you could use `extra_routes` option.

Be aware in case option set in configuration file won't be valid, some unexpected situations might happen. For example, if you set `provider` to `false` but later you will add service provider to module, it won't he loaded unless you change `provider` option to `true` or you remove it completely from configuration file for this module.

### Release notes

[](#release-notes)

Please refer to **[Changelog](https://github.com/mnabialek/laravel-modular/blob/master/CHANGELOG.md)**

#### Licence

[](#licence)

This package is licenced under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~30 days

Recently: every ~36 days

Total

10

Last Release

3392d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/75e68c5eb4daa861595caa21f3d4c6f94ff25118535bc8eac93648b095eab307?d=identicon)[mnabialek](/maintainers/mnabialek)

---

Top Contributors

[![mnabialek](https://avatars.githubusercontent.com/u/7656807?v=4)](https://github.com/mnabialek "mnabialek (120 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mnabialek-laravel-simple-modules/health.svg)

```
[![Health](https://phpackages.com/badges/mnabialek-laravel-simple-modules/health.svg)](https://phpackages.com/packages/mnabialek-laravel-simple-modules)
```

###  Alternatives

[code16/sharp

Laravel Content Management Framework

78959.5k4](/packages/code16-sharp)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3691.5k](/packages/codewithdennis-larament)[ecotone/laravel

Laravel integration for Ecotone

21307.6k3](/packages/ecotone-laravel)

PHPackages © 2026

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