tpetry / laravel-multi-region
Middleware to create multi-region applications with read-after-write consistency
Requires
- php: ^8.4
- laravel/framework: ^13.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pint: ^1.29
- mockery/mockery: ^1.6.13
- orchestra/testbench: ^11.0
- pestphp/pest: ^5.0
- pestphp/pest-plugin-laravel: ^5.0
- pestphp/pest-plugin-phpstan: ^5.2.1
- pestphp/pest-plugin-type-coverage: ^5.0
- phpstan/extension-installer: ^1.4
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Laravel Multi Region Databases
Middleware to create error-free multi-region applications
Installation
You can install the package via Composer:
composer require tpetry/laravel-multi-region
Publishing the Configuration File
php artisan vendor:publish --tag="multiregion-config"
Usage
Testing that every route uses multi-region middleware
A forgotten multiRegionRead(), multiRegionWrite() or noMultiRegion() on a route can lead to stale data. An architecture test can catch them. Add the ExpectsRoutes trait to your tests in tests/Pest.php:
use Tpetry\MultiRegion\Pest\ExpectsRoutes; pest()->extend(TestCase::class) ->use(ExpectsRoutes::class) ->in('Feature', 'Arch');
And create an architecture test, e.g. tests/Arch/MultiRegionTest.php:
arch() ->expectRoutes() ->toUseMultiRegionMiddleware() ->ignoring([ '/up', '/storage/*', 'crm.page.*', ]);
Routes can be ignored by their URI (starting with a slash) or their name. Both may contain wildcards. The test fails for the first route without one of the middleware:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
Laravel Multi Region Databases is open-sourced software licensed under the MIT license.