PHPackages                             selimppc/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. [Framework](/categories/framework)
4. /
5. selimppc/laravel-modules

ActiveLibrary[Framework](/categories/framework)

selimppc/laravel-modules
========================

Lightweight, convention-based modules for Laravel 11/12. Zero request-time overhead. Keeps app migrations by default.

v1.0.0(7mo ago)15MITPHPPHP ^8.3

Since Sep 21Pushed 7mo agoCompare

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

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Modules (lightweight)
=============================

[](#laravel-modules-lightweight)

**selimppc/laravel-modules** — convention-based modular structure for Laravel 11/12:

- Modules live under `/Modules/`
- Keep app migrations in `/database/migrations`
- One auto-discovered provider wires routes/views/translations
- Zero request-time overhead after `route:cache`

Requirements
------------

[](#requirements)

```
PHP 8.3+
Laravel 11 / 12

```

Install
-------

[](#install)

```
$ composer require selimppc/laravel-modules
$ php artisan laravel-modules:install --with-example

```

This will:

- Create /Modules (if missing)
- Publish config/laravel-modules.php
- Publish stubs under /stubs/laravel-modules/module
- Scaffold an Example module and enable it (when using --with-example) ✅ Laravel 12: No need to edit bootstrap/app.php. The service provider is auto-discovered.

Enable modules
--------------

[](#enable-modules)

Edit in `config/laravel-modules.php`:

```
'path' => base_path('Modules'),
'enabled' => [
    'Example' => [
        'web' => ['prefix' => 'example', 'middleware' => ['web'], 'as' => 'example.'],
        'api' => ['prefix' => 'api/example', 'middleware' => ['api'], 'as' => 'example.api.'],
    ],
],

```

Autoload mapping (host app)
---------------------------

[](#autoload-mapping-host-app)

Add PSR-4 for your app (not the package) so Composer can load `Modules\…` classes:

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

```

Rebuild autoload files:

```
$ composer dump-autoload -o

```

#### Try it

[](#try-it)

Start the dev server and visit the example routes:

```
$ php artisan serve

```

Web →

API →

### Make a new module

[](#make-a-new-module)

```
$ php artisan laravel-modules:make Blog

```

Enable it in `config/laravel-modules.php`:

```
'enabled' => [
    'Example' => [...],
    'Blog' => [
        'web' => ['prefix' => 'blog',      'middleware' => ['web'], 'as' => 'blog.'],
        'api' => ['prefix' => 'api/blog',  'middleware' => ['api'], 'as' => 'blog.api.'],
    ],
],

```

Your module structure (convention):

```
Modules/
  Blog/
    routes/web.php
    routes/api.php
    Http/Controllers/...
    Repositories/Contracts/...
    Repositories/Eloquent...
    resources/views/...
    resources/lang/...
    bindings.php      # optional DI bindings for this module

```

| Migrations remain in the host app’s `/database/migrations`.

### Production (performance)

[](#production-performance)

Cache everything:

```
$ php artisan route:cache
$ php artisan config:cache
$ php artisan view:cache

```

Why this is fast:

- Routes are skipped entirely at runtime when cached
- Views/translations are lazy; Blade can be precompiled with view:cache
- No directory scans on requests (uses your config list)

#### Troubleshooting

[](#troubleshooting)

###### Target class does not exist (e.g., Modules\\Example\\Http\\Controllers\\…)

[](#target-class-does-not-exist-eg-modulesexamplehttpcontrollers)

1. Ensure PSR-4 mapping exists in your app’s composer.json (not dev): `"autoload": { "psr-4": { "Modules\\": "Modules/" } }`

Then:

```
$ composer dump-autoload -o
$ php artisan optimize:clear

```

2. Check namespace &amp; casing match the path exactly (case-sensitive FS):

- Modules/Example/Http/Controllers/ExampleController.php
- namespace Modules\\Example\\Http\\Controllers;

3. Clear route/config caches:

```
$ php artisan route:clear
$ php artisan config:clear

```

Verify:

```
$ php artisan route:list | grep example
$ php artisan tinker

>>> class_exists(\Modules\Example\Http\Controllers\ExampleController::class)
Editor warns “Undefined function base_path()”

```

### Customization

[](#customization)

- Disable route autoloading and wire routes yourself:

```
'autoload_routes' => false,

```

- Change module base path (e.g., to `src/Modules`):

```
'path' => base_path('src/Modules'),

```

- Update PSR-4 accordingly:

```
"Modules\\": "src/Modules/"

```

### FAQ

[](#faq)

Q: Can I keep using my global routes and just use modules for controllers/views?

```
A: Yes. Set 'autoload_routes' => false and require your module route files manually or define routes in the app.

```

Q: Where do I put models?

```
A: Inside each module (e.g., Modules/Blog/Models/Post.php) or in your app—your choice. The package is unopinionated here.

```

Q: Can I use repositories/services?

```
A: Yes. Add contracts/implementations under Repositories/... and wire them in bindings.php.

```

### Contributing

[](#contributing)

PRs welcome! Please include tests and update the README when changing behavior. License

MIT © selimppc

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance62

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4429487371badfeeef03e35a3c450a8262cde65131ad481dbe417c5fe56e47b?d=identicon)[selimppc](/maintainers/selimppc)

---

Top Contributors

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

---

Tags

laravelpackagemoduleslightweightdddmodularconvention

### Embed Badge

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

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

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.5k10.6M274](/packages/laravel-boost)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel/wayfinder

Generate TypeScript representations of your Laravel actions and routes.

1.7k4.1M69](/packages/laravel-wayfinder)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

74310.9M66](/packages/laravel-mcp)[internachi/modular

Modularize your Laravel apps

1.1k662.4k8](/packages/internachi-modular)

PHPackages © 2026

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