PHPackages                             tmj/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. tmj/modules

ActiveLibrary[Framework](/categories/framework)

tmj/modules
===========

Laravel Modules

v2.3.5(9y ago)0571BSD-3-ClausePHPPHP &gt;=5.4.0

Since Feb 19Pushed 9y ago2 watchersCompare

[ Source](https://github.com/TMJPEngineering/pingpong-generators)[ Packagist](https://packagist.org/packages/tmj/modules)[ RSS](/packages/tmj-modules/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (6)Versions (56)Used By (0)

Laravel 5 Modules
=================

[](#laravel-5-modules)

- [Upgrade Guide](#upgrade-guide)
- [Installation](#installation)
- [Configuration](#configuration)
- [Naming Convension](#naming-convension)
- [Folder Structure](#folder-structure)
- [Creating Module](#creating-a-module)
- [Artisan Commands](#artisan-commands)
- [Facades](#facades)
- [Entity](#entity)
- [Auto Scan Vendor Directory](#auto-scan-vendor-directory)
- [Publishing Modules](#publishing-modules)

`tmj/modules` is a laravel package which created to manage your large laravel app using modules. Module is like a laravel package, it have some views, controllers or models. This package is supported and tested in both Laravel 4 and Laravel 5. *It was forked from `pingpong/modules`*.

Upgrade Guide
-------------

[](#upgrade-guide)

#### To 2.3

[](#to-23)

If you have been updated to version `2.3`, please read [this release note](https://github.com/TMJPEngineering/pingpong-generators/releases/tag/2.3)

Your config file will looks like [this](https://github.com/TMJPEngineering/pingpong-generators/blob/2.3/src/config/config.php).

#### To 2.0.18

[](#to-2018)

If you have been updated to version `2.0.18`, please read [this release note](https://github.com/pingpong-labs/modules/releases/tag/2.0.18).

#### To 2.0.10

[](#to-2010)

Previously, we add two service provider from this package. In version `2.0.5`, we just need register one service provider. Now, we can remove `Pingpong\Modules\Providers\BootstrapServiceProvider` from `providers` array, because now it service provider is registered automatically by `Pingpong\Modules\ModulesServiceProvider`.

#### From Laravel 4 to Laravel 5

[](#from-laravel-4-to-laravel-5)

If upgrade your Laravel app from Laravel 4 to Laravel 5, there is a few things to do if you are using this package. You will receive some kind errors about config not loaded. To fix this issue, please follow this instruction.

- If you publish the package's configuration file, you need to move the config file from `app/config/packages/pingpong/modules/config.php` to `app/config/modules.php`.
- If you are not publish the package's configuration file and you want to publish the config file, just run `php artisan vendor:publish` command and you are done.

#### From 1.1.\* to 1.2.0

[](#from-11-to-120)

New configuration file. This breaking change affected if you publish the configuration file from this package. To fix this issue, create new config file called `config.php` in your `app/config/packages/pingpong/modules/` directory. Next move the array contents from `paths.php` file to `paths` array in new configuration file. Your config file will looks like [this](https://github.com/TMJPEngineering/pingpong-generators/blob/2.3/src/config/config.php).

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

[](#installation)

To install through composer, simply put the following in your composer.json file:

```
{
    "require": {
        "tmj/modules": "^2.3"
    }
}
```

And then run `composer install` to fetch the package.

#### Quick Installation

[](#quick-installation)

You could also simplify the above code by using the following command:

```
$ composer require tmj/modules

```

#### Add Service Provider

[](#add-service-provider)

Next add the following service provider in `config/app.php`.

```
'providers' => [
    ...
    Pingpong\Modules\ModulesServiceProvider::class
],
```

Next, add the following aliases to `aliases` array in the same file.

```
'aliases' => [
    'Module' => Pingpong\Modules\Facades\Module::class,
],
```

#### Tests

[](#tests)

Add the following directory in `phpunit.xml`.

```
    ...

        ...
        ./modules

    ...
```

Next publish the package's configuration file by run:

```
$ php artisan vendor:publish

```

#### Autoloading

[](#autoloading)

By default controllers, entities or repositories not loaded automatically. You can autoload all that stuff using `psr-4`. For example :

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

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

[](#configuration)

- `modules` - Used for save the generated modules.
- `assets` - Used for save the modules's assets from each modules.
- `migration` - Used for save the modules's migrations if you publish the modules's migrations.
- `generator` - Used for generate modules folders.
- `scan` - Used for allow to scan other folders.
- `enabled` - If `true`, the package will scan other paths. By default the value is `false`
- `paths` - The list of path which can scanned automatically by the package.
- `composer`
    - `vendor` - Composer vendor name.
    - `author.name` - Composer author name.
    - `author.email` - Composer author email.
- `cache`
    - `enabled` - If `true`, the scanned modules (all modules) will cached automatically. By default the value is `false`
    - `key` - The name of cache.
    - `lifetime` - Lifetime of cache.

Creating A Module
-----------------

[](#creating-a-module)

To create a new module you can simply run :

```
$ php artisan module:make

```

- `` - Required. The name of module will be created.

**Create a new module**

```
$ php artisan module:make Blog

```

**Create multiple modules**

```
$ php artisan module:make Blog User Auth

```

By default if you create a new module, that will add some resources like controller, seed class or provider automatically. If you don't want these, you can add `--plain` flag, to generate a plain module.

```
$ php artisan module:make Blog --plain

```

**OR**

```
$ php artisan module:make Blog -p

```

**Naming Convension**

Because we are autoloading the modules using `psr-4`, we strongly recommend using `StudlyCase` convension.

**Folder Structure**

```
laravel-app/
app/
bootstrap/
vendor/
modules/
  ├── Blog/
      ├── Assets/
      ├── Config/
      ├── Console/
      ├── Database/
          ├── Migrations/
          ├── Seeders/
      ├── Entities/
      ├── Events/
      ├── Http/
          ├── Controllers/
          ├── Middleware/
          ├── Requests/
          ├── routes.php
      ├── Interfaces/
      ├── Jobs/
      ├── Listeners/
      ├── Policies/
      ├── Providers/
          ├── BlogServiceProvider.php
      ├── Repositories/
      ├── Resources/
          ├── lang/
          ├── views/
      ├── Repositories/
      ├── Tests/
      ├── composer.json
      ├── module.json
      ├── start.php

```

Artisan Commands
----------------

[](#artisan-commands)

Create new module.

```
$ php artisan module:make blog

```

Use the specified module. Please see [\#26](https://github.com/pingpong-labs/modules/pull/26).

```
$ php artisan module:use blog

```

Show all modules in command line.

```
$ php artisan module:list

```

Create new command for the specified module.

```
$ php artisan module:make-command CustomCommand blog

$ php artisan module:make-command CustomCommand --command=custom:command blog

$ php artisan module:make-command CustomCommand --namespace=Modules\Blog\Commands blog

```

Create new migration for the specified module.

```
$ php artisan module:make-migration create_users_table blog

$ php artisan module:make-migration create_users_table --fields="username:string, password:string" blog

$ php artisan module:make-migration add_email_to_users_table --fields="email:string:unique" blog

$ php artisan module:make-migration remove_email_from_users_table --fields="email:string:unique" blog

$ php artisan module:make-migration drop_users_table blog

```

Rollback, Reset and Refresh The Modules Migrations.

```
$ php artisan module:migrate-rollback

$ php artisan module:migrate-reset

$ php artisan module:migrate-refresh

```

Rollback, Reset and Refresh The Migrations for the specified module.

```
$ php artisan module:migrate-rollback blog

$ php artisan module:migrate-reset blog

$ php artisan module:migrate-refresh blog

```

Create new seed for the specified module.

```
$ php artisan module:make-seed users blog

```

Migrate from the specified module.

```
$ php artisan module:migrate blog

```

Migrate from all modules.

```
$ php artisan module:migrate

```

Seed from the specified module.

```
$ php artisan module:seed blog

```

Seed from all modules.

```
$ php artisan module:seed

```

Create new controller for the specified module.

```
$ php artisan module:make-controller SiteController blog

```

Publish assets from the specified module to public directory.

```
$ php artisan module:publish blog

```

Publish assets from all modules to public directory.

```
$ php artisan module:publish

```

Create new model for the specified module.

```
$ php artisan module:make-model User blog

php artisan module:make-model User blog --fillable="username,email,password"

```

Create new repository for the specified module.

```
$ php artisan module:make-repository UserRepository user

```

Create new policy for the specified module.

```
$ php artisan module:make-policy UserPolicy user

```

Create new event for the specified module.

```
$ php artisan module:make-event SomeEvent user

```

Create new listener for the specified module

```
$ php artisan module:make-listener EventListener user --event=SomeEvent

```

Generate the missing events and listeners for all modules based on registration

```
$ php artisan module:event-generate

```

Create new job for the specified module

```
$ php artisan module:make-job GetUsers user

```

Create new test for the specified module

```
$ php artisan module:make-test ExampleTest user

```

Create new service provider for the specified module.

```
$ php artisan module:make-provider MyServiceProvider blog

```

Publish migration for the specified module or for all modules. This helpful when you want to rollback the migrations. You can also run `php artisan migrate` instead of `php artisan module:migrate` command for migrate the migrations.

For the specified module.

```
$ php artisan module:publish-migration blog

```

For all modules.

```
$ php artisan module:publish-migration

```

Enable the specified module.

```
$ php artisan module:enable blog

```

Disable the specified module.

```
$ php artisan module:disable blog

```

Generate new middleware class.

```
$ php artisan module:make-middleware Auth

```

Update dependencies for the specified module.

```
$ php artisan module:update ModuleName

```

Update dependencies for all modules.

```
$ php artisan module:update

```

Show the list of modules.

```
$ php artisan module:list

```

Facades
-------

[](#facades)

Get all modules.

```
Module::all();
```

Get all cached modules.

```
Module::getCached()
```

Get ordered modules. The modules will be ordered by the `priority` key in `module.json` file.

```
Module::getOrdered();
```

Get scanned modules.

```
Module::scan();
```

Find a specific module.

```
Module::find('name');
```

**OR**

```
Module::get('name');
```

Find a module, if there is one, return the `Module` instance, otherwise throw `Pingpong\Modules\Exeptions\ModuleNotFoundException`.

```
Module::findOrFail('module-name');
```

Get scanned paths.

```
Module::getScanPaths();
```

Get all modules as a collection instance.

```
Module::toCollection();
```

Get modules by the status. 1 for active and 0 for inactive.

```
Module::getByStatus(1);
```

Check the specified module. If it exists, will return `true`, otherwise `false`.

```
Module::has('blog');
```

Get all enabled modules.

```
Module::enabled();
```

Get all disabled modules.

```
Module::disabled();
```

Get count of all modules.

```
Module::count();
```

Get module path.

```
Module::getPath();
```

Register the modules.

```
Module::register();
```

Boot all available modules.

```
Module::boot();
```

Get all enabled modules as collection instance.

```
Module::collections();
```

Get module path from the specified module.

```
Module::getModulePath('name');
```

Get assets path from the specified module.

```
Module::getAssetPath('name');
```

Get config value from this package.

```
Module::config('composer.vendor');
```

Get used storage path.

```
Module::getUsedStoragePath();
```

Get used module for cli session.

```
Module::getUsedNow();
```

**OR**

```
Module::getUsed();
```

Set used module for cli session.

```
Module::setUsed('name');
```

Get modules's assets path.

```
Module::getAssetsPath();
```

Get asset url from specific module.

```
Module::asset('blog:img/logo.img');
```

Install the specified module by given module name.

```
Module::install('pingpong-modules/hello');
```

Update dependencies for the specified module.

```
Module::update('hello');
```

Module Entity
-------------

[](#module-entity)

Get an entity from a specific module.

```
$module = Module::find('blog');
```

Get module name.

```
$module->getName();

```

Get module name in lowercase.

```
$module->getLowerName();

```

Get module name in studlycase.

```
$module->getStudlyName();

```

Get module path.

```
$module->getPath();

```

Get extra path.

```
$module->getExtraPath('Assets');

```

Disable the specified module.

```
$module->enable();

```

Enable the specified module.

```
$module->disable();

```

Delete the specified module.

```
$module->delete();

```

Custom Namespaces
-----------------

[](#custom-namespaces)

When you create a new module it also registers new custom namespace for `Lang`, `View` and `Config`. For example, if you create a new module named blog, it will also register new namespace/hint blog for that module. Then, you can use that namespace for calling `Lang`, `View` or `Config`. Following are some examples of its usage:

Calling Lang:

```
Lang::get('blog::group.name');
```

Calling View:

```
View::make('blog::index')

View::make('blog::partials.sidebar')
```

Calling Config:

```
Config::get('blog.name')
```

Publishing Modules
------------------

[](#publishing-modules)

Have you created a laravel modules? Yes, I've. Then, I want to publish my modules. Where do I publish it? That's the question. What's the answer ? The answer is [Packagist](http://packagist.org). In pingpong/modules version &gt;= 1.2.0, when you generate a module, you will see there is a new file generated called `composer.json`.

### Auto Scan Vendor Directory

[](#auto-scan-vendor-directory)

By default the `vendor` directory is not scanned automatically, you need to update the configuration file to allow that. Set `scan.enabled` value to `true`. For example :

```
// file config/modules.php

return [
  //...
  'scan' => [
    'enabled' => true
  ]
  //...
]
```

You can verify the module has been installed using `module:list` command:

```
$ php artisan module:list

```

Publishing Modules
------------------

[](#publishing-modules-1)

After creating a module and you are sure your module module will be used by other developers. You can push your module to [github](https://github.com) or [bitbucket](https://bitbucket.org) and after that you can submit your module to the packagist website.

You can follow this step to publish your module.

1. Create A Module.
2. Push the module to github.
3. Submit your module to the packagist website. Submit to packagist is very easy, just give your github repository, click submit and you done.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 88.5% 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 ~21 days

Recently: every ~14 days

Total

55

Last Release

3365d ago

Major Versions

1.0.x-dev → 2.0.02015-05-08

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.0.1PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/21231662?v=4)[Cons](/maintainers/jcmlumacad)[@jcmlumacad](https://github.com/jcmlumacad)

---

Top Contributors

[![gravitano](https://avatars.githubusercontent.com/u/5087538?v=4)](https://github.com/gravitano "gravitano (331 commits)")[![nWidart](https://avatars.githubusercontent.com/u/882397?v=4)](https://github.com/nWidart "nWidart (15 commits)")[![noxify](https://avatars.githubusercontent.com/u/521777?v=4)](https://github.com/noxify "noxify (11 commits)")[![SubodhDahal](https://avatars.githubusercontent.com/u/1782292?v=4)](https://github.com/SubodhDahal "SubodhDahal (2 commits)")[![blackakula](https://avatars.githubusercontent.com/u/156983?v=4)](https://github.com/blackakula "blackakula (2 commits)")[![joearcher](https://avatars.githubusercontent.com/u/1125046?v=4)](https://github.com/joearcher "joearcher (1 commits)")[![memeq1](https://avatars.githubusercontent.com/u/5739180?v=4)](https://github.com/memeq1 "memeq1 (1 commits)")[![moston](https://avatars.githubusercontent.com/u/2960288?v=4)](https://github.com/moston "moston (1 commits)")[![prhost](https://avatars.githubusercontent.com/u/3984760?v=4)](https://github.com/prhost "prhost (1 commits)")[![sonus](https://avatars.githubusercontent.com/u/2891670?v=4)](https://github.com/sonus "sonus (1 commits)")[![syahzul](https://avatars.githubusercontent.com/u/707301?v=4)](https://github.com/syahzul "syahzul (1 commits)")[![tlikai](https://avatars.githubusercontent.com/u/1356974?v=4)](https://github.com/tlikai "tlikai (1 commits)")[![aaronflorey](https://avatars.githubusercontent.com/u/948073?v=4)](https://github.com/aaronflorey "aaronflorey (1 commits)")[![xLink](https://avatars.githubusercontent.com/u/217433?v=4)](https://github.com/xLink "xLink (1 commits)")[![ahmadina](https://avatars.githubusercontent.com/u/5356553?v=4)](https://github.com/ahmadina "ahmadina (1 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![f0ntana](https://avatars.githubusercontent.com/u/6570783?v=4)](https://github.com/f0ntana "f0ntana (1 commits)")[![Jastkast](https://avatars.githubusercontent.com/u/3151045?v=4)](https://github.com/Jastkast "Jastkast (1 commits)")

---

Tags

laravelmodulemoduleshmvcpingpong

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tmj-modules/health.svg)

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

###  Alternatives

[pingpong/modules

Laravel Modules

576190.1k13](/packages/pingpong-modules)[unopim/unopim

UnoPim Laravel PIM

10.5k2.2k](/packages/unopim-unopim)[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)[artem-schander/l5-modular

Modular pattern generator for Laravel

217239.7k](/packages/artem-schander-l5-modular)[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)

PHPackages © 2026

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