Download the PHP package dandysi/laravel-monorepo without Composer
On this page you can find all versions of the php package dandysi/laravel-monorepo. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dandysi/laravel-monorepo
More information about dandysi/laravel-monorepo
Files in dandysi/laravel-monorepo
Package laravel-monorepo
Short Description A set of tools to make working with a monorepo of related Laravel microservices easier
License MIT
Informations about the package laravel-monorepo
Laravel Monorepo
This package allows you to create a monorepo of related Laravel microservices, that share common libraries and backend services/technologies.
Demo
A demo repository using this package containing three related Laravel microservices.
https://github.com/dandysi-labs/demo-laravel-monorepo
Install
Create Provider
If you intend to use the normal Laravel directory structure:
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):
This will create the file microservices/Chores/MonorepoProvider..php with the namespace Chores
...and update your composer.json autoload paths accordingly:
Next Step
Start writing your code as you normally would, albeit using the monorepo provider to setup the service.
Routes
Add routes as usual (this function will not be called if routes are already cached).
Commands
Register command classes.
Schedules
Events
Register event listeners:
Register event subscribers:
Config
To include isolated config data (this function will not be called if config already cached):
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)
...and create a function to perform the modification in the monorepo provider:
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.
This will create the file microservices/Chores/Tests/TestCase.php with the namespace Chores\Tests and use the Chores\MonorepoProvider class
Using
To use your new microservice, simply update the environment variable MONOREPO_PROVIDER to point to the relevant monorepo provider class:
To quickly run a command, prefix the command with the env
Or serve some routes
Additional Providers
Simply create a new provider and repeat.
License
Open-sourced software licensed under the MIT license.