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

ActiveLibrary[Framework](/categories/framework)

hassankerdash/laravel-modular
=============================

Modularize your Laravel apps

0.3(2y ago)024MITPHPPHP &gt;=8.0

Since Mar 17Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (7)Versions (4)Used By (0)

`hassankerdash/laravel-modular`
===============================

[](#hassankerdashlaravel-modular)

`hassankerdash/laravel-modular` is a module system for Laravel applications. It uses [Composer path repositories](https://getcomposer.org/doc/05-repositories.md#path) for autoloading, and [Laravel package discovery](https://laravel.com/docs/7.x/packages#package-discovery) for module initialization, and then provides minimal tooling to fill in any gaps.

This project is as much a set of conventions as it is a package. The fundamental idea is that you can create “modules” in a separate `modules/` directory, which allows you to better organize large projects. These modules use the existing [Laravel package system](https://laravel.com/docs/7.x/packages), and follow existing Laravel conventions.

- [Installation](#installation)
- [Usage](#usage)

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

[](#installation)

To get started, run:

```
composer require hassankerdash/laravel-modular
```

Laravel will auto-discover the package and everything will be automatically set up for you.

### Publish the config

[](#publish-the-config)

While not required, it's highly recommended that you customize your default namespace for modules. By default, this is set to `Modules\`, which works just fine but makes it harder to extract your module to a separate package should you ever choose to.

We recommend configuring a organization namespace (we use `"HassanKerdash"`, for example). To do this, you'll need to publish the package config:

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

### Create a module

[](#create-a-module)

Next, let's create a module:

```
php artisan make:module my-module
```

Modular will scaffold up a new module for you:

```
modules/
  my-module/
    composer.json
    src/
    tests/
    routes/
    resources/
    database/

```

It will also add two new entries to your app's `composer.json` file. The first entry registers `./modules/my-module/` as a [path repository](https://getcomposer.org/doc/05-repositories.md#path), and the second requires `modules/my-module:*` (like any other Composer dependency).

Modular will then remind you to perform a Composer update, so let's do that now:

```
composer update modules/my-module
```

### Optional: Config synchronization

[](#optional-config-synchronization)

You can run the sync command to make sure that your project is set up for module support:

```
php artisan modules:sync
```

This will add a `Modules` test suite to your `phpunit.xml` file (if one exists) and update your [PhpStorm Laravel plugin](https://plugins.jetbrains.com/plugin/7532-laravel)configuration (if it exists) to properly find your module's views.

It is safe to run this command at any time, as it will only add missing configurations. You may even want to add it to your `post-autoload-dump` scripts in your application's `composer.json` file.

Usage
-----

[](#usage)

All modules follow existing Laravel conventions, and auto-discovery should work as expected in most cases:

- Commands are auto-registered with Artisan
- Migrations will be run by the Migrator
- Factories are auto-loaded for `factory()`
- Policies are auto-discovered for your Models
- Blade components will be auto-discovered
- Event listeners will be auto-discovered

### Commands

[](#commands)

#### Package Commands

[](#package-commands)

We provide a few helper commands:

- `php artisan make:module` — scaffold a new module
- `php artisan modules:cache` — cache the loaded modules for slightly faster auto-discovery
- `php artisan modules:clear` — clear the module cache
- `php artisan modules:sync` — update project configs (like `phpunit.xml`) with module settings
- `php artisan modules:list` — list all modules

#### Laravel “`make:`” Commands

[](#laravel-make-commands)

We also add a `--module=` option to most Laravel `make:` commands so that you can use all the existing tooling that you know. The commands themselves are exactly the same, which means you can use your [custom stubs](https://laravel.com/docs/7.x/artisan#stub-customization)and everything else Laravel provides:

- `php artisan make:cast MyModuleCast --module=[module name]`
- `php artisan make:controller MyModuleController --module=[module name]`
- `php artisan make:command MyModuleCommand --module=[module name]`
- `php artisan make:component MyModuleComponent --module=[module name]`
- `php artisan make:channel MyModuleChannel --module=[module name]`
- `php artisan make:event MyModuleEvent --module=[module name]`
- `php artisan make:exception MyModuleException --module=[module name]`
- `php artisan make:factory MyModuleFactory --module=[module name]`
- `php artisan make:job MyModuleJob --module=[module name]`
- `php artisan make:listener MyModuleListener --module=[module name]`
- `php artisan make:mail MyModuleMail --module=[module name]`
- `php artisan make:middleware MyModuleMiddleware --module=[module name]`
- `php artisan make:model MyModule --module=[module name]`
- `php artisan make:notification MyModuleNotification --module=[module name]`
- `php artisan make:observer MyModuleObserver --module=[module name]`
- `php artisan make:policy MyModulePolicy --module=[module name]`
- `php artisan make:provider MyModuleProvider --module=[module name]`
- `php artisan make:request MyModuleRequest --module=[module name]`
- `php artisan make:resource MyModule --module=[module name]`
- `php artisan make:rule MyModuleRule --module=[module name]`
- `php artisan make:seeder MyModuleSeeder --module=[module name]`
- `php artisan make:test MyModuleTest --module=[module name]`

#### Other Laravel Commands

[](#other-laravel-commands)

In addition to adding a `--module` option to most `make:` commands, we’ve also added the same option to the `db:seed` command. If you pass the `--module` option to `db:seed`, it will look for your seeder within your module namespace:

- `php artisan db:seed --module=[module name]` will try to call `Modules\MyModule\Database\Seeders\DatabaseSeeder`
- `php artisan db:seed --class=MySeeder --module=[module name]` will try to call `Modules\MyModule\Database\Seeders\MySeeder`

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Total

3

Last Release

785d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/38482f5c31b469b9359a4095b0da1e66d211df5bd6eaecf4f180e18eb04ae0fb?d=identicon)[HassanKerdash](/maintainers/HassanKerdash)

---

Top Contributors

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

---

Tags

laravelmodulemodulesmodular

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[internachi/modular

Modularize your Laravel apps

1.1k662.4k8](/packages/internachi-modular)[artem-schander/l5-modular

Modular pattern generator for Laravel

223235.5k](/packages/artem-schander-l5-modular)[pingpong/modules

Laravel Modules

592188.7k13](/packages/pingpong-modules)

PHPackages © 2026

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