PHPackages                             dandysi/laravel-monorepo - 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. dandysi/laravel-monorepo

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

dandysi/laravel-monorepo
========================

A set of tools to make working with a monorepo of related Laravel microservices easier

v1.0.0(2y ago)05MITPHPPHP ^8.1

Since Jan 2Pushed 2y agoCompare

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

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Laravel Monorepo
================

[](#laravel-monorepo)

[![Actions Status](https://github.com/dandysi-labs/laravel-monorepo/workflows/Tests/badge.svg)](https://github.com/dandysi-labs/laravel-monorepo/actions)

This package allows you to create a monorepo of related Laravel microservices, that share common libraries and backend services/technologies.

Demo
----

[](#demo)

A demo repository using this package containing three related Laravel microservices.

Install
-------

[](#install)

```
composer require dandysi/laravel-monorepo
```

Create Provider
---------------

[](#create-provider)

If you intend to use the normal Laravel directory structure:

```
php artisan make:monorepo-provider Chores
```

> This will create the file **app/Chores/MonorepoProvider.php** with the namespace **App\\Chores**

Outside of the normal then you will need to specify the destination directory (this will be relative to the project root):

```
php artisan make:monorepo-provider Chores microservices/Chores
```

> This will create the file **microservices/Chores/MonorepoProvider..php** with the namespace **Chores**

...and update your composer.json autoload paths accordingly:

```
"autoload": {
    "psr-4": {
        "Chores\\": "microservices/Chores"
    }
}
```

Next Step
---------

[](#next-step)

Start writing your code as you normally would, albeit using the monorepo provider to setup the service.

### Routes

[](#routes)

Add routes as usual (this function will not be called if routes are already cached).

```
use Illuminate\Support\Facades\Route;

protected function configureRoutes()
{
    Route::middleware('api')
        ->prefix('api')
        ->group(__DIR__ . '/routes.php')
    ;
}
```

### Commands

[](#commands)

Register command classes.

```
use Chores\Console\ExpireArticlesCommand;

protected function registerCommands(): array
{
    return [
        ExpireArticlesCommand::class
    ];
}
```

### Schedules

[](#schedules)

```
use Illuminate\Console\Scheduling\Schedule;

protected function registerSchedule(Schedule $schedule): void
{
    $schedule->command(ExpireArticlesCommand::class)->daily();
}
```

### Events

[](#events)

Register event listeners:

```
protected function registerEventListeners(): array
{
    return [
        ArticleCreated::class => [
            UpdateArticleCachListener::class
        ],
        ArticleDeleted::class => [
            UpdateArticleCachListener::class
        ]
    ];
}
```

Register event subscribers:

```
protected function registerEventSubscribers(): array
{
    return [
        UpdateArticleCacheSubscriber::class
    ];
}
```

### Config

[](#config)

To include isolated config data (this function will not be called if config already cached):

```
protected function registerConfig(): array
{
    return [
        'chores' => require __DIR__ . '/config.php'
    ];
}
```

If however you would like to tweak a normal config file further than just updating an environment variable, wrap the existing value(s) in a function call (this must be the base class and the method must end in **Config**)

```
// config/database.php
use Dandysi\Laravel\Monorepo\MonorepoProvider;

return [
    'connections' => MonorepoProvider::dbConnectionsConfig([
        'sqlite' => [
            'driver' => 'sqlite',
            'url' => env('DATABASE_URL'),
            'database' => env('DB_DATABASE', database_path('database.sqlite')),
            'prefix' => '',
            'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
        ]
    ])
];
```

...and create a function to perform the modification in the monorepo provider:

```
// microservices/Chores/MonorepoPrvider.php

public static function dbConnectionsConfig(array $default): array
{
    $default['new_db'] => [
        // ...
    ];

    return $default;
}
```

Testing
-------

[](#testing)

As routes, configs, commands, schedules, events are all isolated, testing is slightly more complicated. However, there is another make command to help. This will generate a test case for you to extend in your tests, effectively setting up the related microservice.

```
php artisan make:monorepo-test-case Chores/Tests microservices/Chores/Tests Chores
```

> This will create the file **microservices/Chores/Tests/TestCase.php** with the namespace **Chores\\Tests** and use the **Chores\\MonorepoProvider** class

Using
-----

[](#using)

To use your new microservice, simply update the environment variable MONOREPO\_PROVIDER to point to the relevant monorepo provider class:

```
MONOREPO_PROVIDER=Chores\\MonorepoProvider

```

To quickly run a command, prefix the command with the env

```
MONOREPO_PROVIDER=Chores\\MonorepoProvider php artisan chores:some_command
```

Or serve some routes

```
MONOREPO_PROVIDER=Chores\\MonorepoProvider php artisan serve
```

Additional Providers
--------------------

[](#additional-providers)

Simply create a new provider and repeat.

License
-------

[](#license)

Open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

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

862d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/117f0c641b9b88e52a4c66df2335061ca98300c80e9a2a170e540e4910e18367?d=identicon)[syadmz](/maintainers/syadmz)

---

Top Contributors

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

---

Tags

microservicesmonorepo

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dandysi-laravel-monorepo/health.svg)

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[pulkitjalan/ip-geolocation

IP Geolocation Wrapper with Laravel Support

89164.9k1](/packages/pulkitjalan-ip-geolocation)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

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