PHPackages                             llama-laravel/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. llama-laravel/modules

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

llama-laravel/modules
=====================

Laravel Module Management

v1.1.2(8y ago)02671MITPHPPHP &gt;=5.6.4

Since Jun 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/xuanhoa88/laravel-modules)[ Packagist](https://packagist.org/packages/llama-laravel/modules)[ RSS](/packages/llama-laravel-modules/feed)WikiDiscussions master Synced 2mo ago

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

Laravel-Modules
===============

[](#laravel-modules)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dfd441e8ccab95600fabf66075e39d0522c60618fc4a5d8aecf8fcaf61f23a25/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6c616d612d6c61726176656c2f6d6f64756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/llama-laravel/modules)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/c4e1e7ca0432ca6e0a27e96cee42e652e228c590fcf7567374168c30a2e80abe/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c6c616d612d6c61726176656c2f6d6f64756c65732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/llama-laravel/modules)[![Scrutinizer Coverage](https://camo.githubusercontent.com/fc04363a6122ad23855040e506a6e0ce81dc16c1a8434f816b0b0dba2787d7ca/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c6c616d612d6c61726176656c2f6d6f64756c65732e7376673f6d61784167653d3836343030267374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/llama-laravel/modules/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/03e2e7bc2797f037c0a1869dc105899f2e38ae54fb1764bac672ed8cfae9bbe8/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f32353332306130382d386166342d343735652d613233652d3333323166353562663864322e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/25320a08-8af4-475e-a23e-3321f55bf8d2)[![Quality Score](https://camo.githubusercontent.com/828df853add0ac287c2e0f30e4d6b7e139ffaa6131cc8b9a7c049e7a98f71fac/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c6c616d612d6c61726176656c2f6d6f64756c65732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/llama-laravel/modules)[![Total Downloads](https://camo.githubusercontent.com/bd2163c5dbc37a8cdc4d27f178db1d41dd5b88969664a9d61f2409c558c320de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6c616d612d6c61726176656c2f6d6f64756c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/llama-laravel/modules)

- [Upgrade Guide](#upgrade-guide)
- [Installation](#installation)
- [Configuration](#configuration)
- [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)

`llama-laravel/modules` is a laravel package which created to manage your large laravel app using modules. Module is like a laravel package, it has some views, controllers or models.

This package is supported and tested in Laravel 5.

This package was inspired by [nwidart/laravel-modules](https://github.com/nWidart/laravel-modules).

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

[](#upgrade-guide)

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

[](#installation)

### Quick

[](#quick)

To install through composer, simply run the following command:

```
composer require llama-laravel/modules
```

#### Add Service Provider

[](#add-service-provider)

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

```
'providers' => [
  Llama\Modules\ModuleServiceProvider::class,
],
```

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

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

Next publish the package's configuration file by running:

```
php artisan vendor:publish --provider="Llama\Modules\ModuleServiceProvider"

```

#### Autoloading

[](#autoloading)

By default controllers, entities or repositories are not loaded automatically. You can autoload your modules using `psr-4`. For example:

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

After that, you must run statement below for dumps the autoloader:

```
composer dump-autoload -o
```

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.
- `seed` - Used for save the modules's seeds if you publish the modules's seeds.
- `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.

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  --plain
#OR
php artisan module:make  -p
```

**Naming Convention**

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

**Folder Structure**

```
your-laravel/app/Modules/
  ├── Blog/
      ├── Config/
      ├── Database/
          ├── Seeds/
      ├── Http/
          ├── Controllers/
      ├── Providers/
      ├── Resources/
          ├── assets/
          ├── lang/
          ├── views/
      ├── Routes/
          ├── web.php
          ├── api.php
      ├── composer.json
      ├── module.json

```

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

[](#artisan-commands)

You must be setting up modules folder for first use

```
php artisan module:setup

```

Create new module.

```
php artisan module:make blog

```

Use the specified module.

```
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
#OR
php artisan module:make-command CustomCommand --command=custom:command blog

```

Create new migration for the specified module.

```
php artisan module:make-migration create_users_table blog
#OR
php artisan module:make-migration create_users_table blog --create=users
#OR
php artisan module:make-migration add_email_to_users_table blog --table=users

```

Rollback, Reset and Refresh The Modules Migrations.

```
php artisan module:migrate-rollback
#OR
php artisan module:migrate-reset
#OR
php artisan module:migrate-refresh

```

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

```
php artisan module:migrate-rollback blog
#OR
php artisan module:migrate-reset blog
#OR
php artisan module:migrate-refresh blog

```

Migrate from the specified module.

```
php artisan module:migrate blog

```

Migrate from all modules.

```
php artisan module:migrate

```

Create new seeder for the specified module.

```
php artisan module:make-seeder PostsTableSeeder blog

```

Seed from the specified module.

```
php artisan module:db-seed blog

```

Seed from all modules.

```
php artisan module:db-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:link blog

```

Publish assets from all modules to public directory.

```
php artisan module:link

```

Create new model for the specified module.

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

```

Create new service provider for the specified module.

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

```

Create new policy for the specified module.

```
php artisan module:make-policy PostsPolicy blog

```

Create new route provider for the specified module.

```
php artisan module:make-route blog

```

Create new form request for the specified module.

```
php artisan module:make-request CreateRequest blog

```

Create new event for the specified module.

```
php artisan module:make-event CreateEvent blog

```

Create new job for the specified module.

```
php artisan module:make-job CreateJob blog

```

Create new listener for the specified module.

```
php artisan module:make-listener CreateListener blog --event="App\Modules\Blog\Events\CreateEvent"

```

Create new middleware for the specified module.

```
php artisan module:make-middleware CreateNewPostMiddleware blog

```

Create new mail for the specified module.

```
php artisan module:make-mail WelcomeEmail checkout
#OR
php artisan module:make-mail WelcomeEmail checkout --markdown=emails.checkout.shipped

```

Create new notification for the specified module.

```
php artisan module:make-notification InvoicePaid checkout
#OR
php artisan module:make-notification InvoicePaid checkout --markdown=notifications.checkout.shipped

```

Enable the specified module.

```
php artisan module:enable blog

```

Disable the specified module.

```
php artisan module:disable blog

```

Update dependencies for the specified module.

```
php artisan module:update blog

```

Update dependencies for all modules.

```
php artisan module:update

```

Show the list of modules.

```
php artisan module:list

```

Facades
-------

[](#facades)

### Using Model Factories

[](#using-model-factories)

Normally, you can use [model factories](https://laravel.com/docs/5.4/database-testing#writing-factories) to conveniently generate large amounts of database records. I have defined new way to writing seeder for the specified module.

```
Module::factory(App\User::class, 50)->create()->each(function ($u) {
    $u->posts()->save(factory(App\Post::class)->make());
});
```

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 `Llama\Modules\Exeptions\ModuleNotFoundException`.

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

Get scanned locations.

```
Module::getScannedLocations();
```

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::activated();
```

Get all disabled modules.

```
Module::deactivated();
```

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::assetPath('name');
```

Get config value from this package.

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

Get used storage path.

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

Get used module for cli session.

```
Module::used();
```

Set used module for cli session.

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

Get modules's assets path.

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

Get modules's namespace.

```
Module::getNamespace();
```

Get asset url from specific module.

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

Install the specified module by given module name.

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

Update dependencies for the specified module.

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

Entity
------

[](#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->disable();
```

Enable the specified module.

```
$module->enable();
```

Delete the specified module.

```
$module->delete();
```

Get namespace specified module.

```
$module->getNamespace();
```

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');
#OR
trans('blog::group.name');
```

Calling View:

```
View::make('blog::index');
#OR
View::make('blog::partials.sidebar');
```

Calling Config:

```
Config::get('blog.name');
#OR
config('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).

### 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.

Credits
-------

[](#credits)

- [XuaNguyen](https://github.com/xuanhoa88)
- [All Contributors](../../contributors)

About XuaNguyen
---------------

[](#about-xuanguyen)

XuaNguyen is a freelance web developer specialising on the laravel framework.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

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 ~9 days

Total

5

Last Release

3229d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8601be70d0d3d5a02c55b5aca4b1ee0d762370b77b95bdb8bce9f6a68a7d0827?d=identicon)[xuanhoa88](/maintainers/xuanhoa88)

---

Top Contributors

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

---

Tags

frameworklaravelllamamoduleslaravelmodulellama

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)

PHPackages © 2026

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