PHPackages                             zenphp/modulr - 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. zenphp/modulr

ActiveLibrary[Framework](/categories/framework)

zenphp/modulr
=============

Turn your Laravel applications modular with Modulr!

v1.3.0(1mo ago)11.3k1MITPHPPHP ^8.4CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/zenphporg/modulr)[ Packagist](https://packagist.org/packages/zenphp/modulr)[ RSS](/packages/zenphp-modulr/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (10)Dependencies (22)Versions (21)Used By (1)

[![Zen Foundation](https://raw.githubusercontent.com/zenphporg/.github/main/img/zenphp.png)](https://raw.githubusercontent.com/zenphporg/.github/main/img/zenphp.png)

[![Coverage](https://camo.githubusercontent.com/59d398c8e07337ebc7a41ab9260982a9447e49502901c1135bb1d6e0812b6719/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f786d6c3f636f6c6f723d73756363657373266c6162656c3d636f7665726167652671756572793d726f756e64253238253246253246636f76657261676525324670726f6a6563742532466d657472696373253246253430636f7665726564656c656d656e7473253230646976253230253246253246636f76657261676525324670726f6a6563742532466d657472696373253246253430656c656d656e7473253230253241253230313030253239267375666669783d2532352675726c3d68747470732533412532462532467261772e67697468756275736572636f6e74656e742e636f6d2532467a656e7068706f72672532466d6f64756c722532466d61696e253246636c6f7665722e786d6c)](https://github.com/zenphporg/modulr/blob/main/clover.xml)[![Build Status](https://camo.githubusercontent.com/3a853deebe1d38e023b9c88f57b11712e3dc661574dcb9725b05df25b5b9fb96/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a656e7068706f72672f6d6f64756c722f6d61696e74656e616e63652e796d6c)](https://github.com/zenphporg/modulr/actions)[![Total Downloads](https://camo.githubusercontent.com/9fb19b8234512d7cad04fdd4ed4f4f5b36b6b503175199f258d40d0cc50f0dc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e7068702f6d6f64756c72)](https://packagist.org/packages/zenphp/modulr)[![Latest Stable Version](https://camo.githubusercontent.com/0afbd6b9a0359883168353884625b1ccaff7595bfb20b6854c30797515f3941c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e7068702f6d6f64756c72)](https://packagist.org/packages/zenphp/modulr)[![License](https://camo.githubusercontent.com/974cc358f044787cb143b2c3dda5fbd1960e3358f95067c0112b3f113473fe81/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a656e7068702f6d6f64756c72)](https://packagist.org/packages/zenphp/modulr)

About Modulr
------------

[](#about-modulr)

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

Modulr is a reworking of [InterNACHI/modular](https://github.com/InterNACHI/modular) and expands on a few concepts like modulizing existing composer packages with ease using our `modules:install` command. Being able to bring packages into your app that are normally out of range in the vendor folder gives you a huge amount of flexibility, without the added burden of having to maintain your own package.

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/10.x/packages), and follow existing Laravel conventions.

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

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

[](#installation)

To get started, run:

```
composer require zenphp/modulr
```

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 an organization namespace (we use `"ZenPHP"`, for example). To do this, you'll need to publish the package config:

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

### Create a module

[](#create-a-module)

Next, let's create a module:

```
php artisan modules:make
```

Modulr uses [Laravel Prompts](https://laravel.com/docs/prompts) to provide an interactive module creation experience. You'll be guided through:

1. **Module name** — Enter a name for your module (e.g., `billing`, `user-management`)
2. **Components** — Select which components to generate (model, controller, migration, factory, etc.)
3. **Component options** — Configure options for selected components:
    - **Model**: Include factory, migration, seeder, policy, or controller
    - **Controller**: Choose type (resource, API, invokable, singleton, or plain)
    - **Mail/Notification**: Include markdown template
    - **Component**: Use inline view
    - **Event**: Also create a listener

You can also pass the module name directly to skip the first prompt:

```
php artisan modules:make companies
```

Or create an empty module structure with just the namespace:

```
php artisan modules:make companies --empty
```

It will also add two new entries to your app's `composer.json` file. The first entry registers `./modules/companies/` as a [path repository](https://getcomposer.org/doc/05-repositories.md#path), and the second requires `modules/companies:*` (like any other Composer dependency). Modulr will then automatically run `composer update` to install the new 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 modules:make` — scaffold a new module (--empty for and empty module directory)
- `php artisan modules:install` - install any registered composer package as a 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`

#### Blade Components

[](#blade-components)

Your [Laravel Blade components](https://laravel.com/docs/blade#components) will be automatically registered for you under a [component namespace](https://laravel.com/docs/9.x/blade#manually-registering-package-components).

A few examples:

FileComponent`modules/demo/src/View/Components/Basic.php````modules/demo/src/View/Components/Nested/One.php````modules/demo/src/View/Components/Nested/Two.php````modules/demo/resources/components/anonymous.blade.php````modules/demo/resources/components/anonymous/index.blade.php````modules/demo/resources/components/anonymous/nested.blade.php```#### Customizing the Default Module Structure

[](#customizing-the-default-module-structure)

When you call `modules:make`, Modulr will scaffold some basic boilerplate for you. If you would like to customize this behavior, you can do so by publishing the `modules.php` config file and adding your own stubs.

Both filenames and file contents support a number of placeholders. These include:

- `StubBasePath`
- `StubModuleNamespace`
- `StubComposerNamespace`
- `StubModuleNameSingular`
- `StubModuleNamePlural`
- `StubModuleName`
- `StubClassNamePrefix`
- `StubComposerName`
- `StubMigrationPrefix`
- `StubFullyQualifiedTestCaseBase`
- `StubTestCaseBase`

### Extending Controller Generation

[](#extending-controller-generation)

When creating a module with a controller, Modulr dispatches a `ControllerPromptsCollecting` event that allows other packages to add their own options to the controller generation process.

To listen for this event, register a listener in your service provider:

```
use Zen\Modulr\Events\ControllerPromptsCollecting;

Event::listen(ControllerPromptsCollecting::class, function (ControllerPromptsCollecting $event) {
    // Access context about the controller being created
    $controllerType = $event->controllerType; // 'resource', 'api', 'invokable', or 'plain'
    $moduleName = $event->moduleName;
    $className = $event->className;

    // Add additional options to be passed to make:controller
    $event->addOption('--requests', true);
});
```

The options added via `addOption()` will be merged into the `make:controller` command arguments.

---

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](https://github.com/zenphporg/modulr/security/policy) on how to report security vulnerabilities.

License
-------

[](#license)

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

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance88

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 72.3% 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 ~41 days

Recently: every ~25 days

Total

20

Last Release

59d ago

PHP version history (3 changes)v1.0.0PHP ^8.2

v1.0.8PHP ^8.3

v1.1.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c31e2989d4b46bff753da02ddc5501063ccbe5c889ae6b4e4f186b1564a93b9?d=identicon)[secondmanveran](/maintainers/secondmanveran)

---

Top Contributors

[![secondmanveran](https://avatars.githubusercontent.com/u/97000801?v=4)](https://github.com/secondmanveran "secondmanveran (47 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (18 commits)")

---

Tags

laravelmodulesmodulr

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

### Embed Badge

![Health badge](/badges/zenphp-modulr/health.svg)

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

###  Alternatives

[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k95.4M306](/packages/laravel-horizon)[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[internachi/modular

Modularize your Laravel apps

1.2k849.5k16](/packages/internachi-modular)[laravel/surveyor

Static analysis tool for Laravel applications.

86121.4k13](/packages/laravel-surveyor)

PHPackages © 2026

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