shrink / conductor-laravel
Laravel runtime dependency checks for Conductor
Requires
- php: ^8.0.2
- illuminate/database: ^9.0
- illuminate/http: ^9.0
- illuminate/routing: ^9.0
- illuminate/support: ^9.0
- shrink/conductor: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^4.3
README
Conductor checks the status of runtime dependencies, Conductor: Laravel is a set of Laravel runtime dependency checks.
Scenario: I have a containerised Laravel application, I want to deploy a new version which includes database migrations. How do I prevent the new version from running against a database that has yet to be migrated?
Usage
- Install the library with composer
- Enable Conductor with the optional Service Provider
- Define your application's runtime dependencies
↓ Jump to Dependencies available for Laravel
Install
dev:~$ composer require shrink/conductor-laravel
Enable
An optional out-of-the-box Service Provider registers the necessary instances (with sane default configuration) in the Laravel container.
'providers' => [
// ...
+ Shrink\Conductor\Laravel\Conductor::class,
// ...
];
Define Dependencies
Add a Dependency to the Collection with a string id
and an instance of a
Shrink\Conductor\ChecksDependencyStatus
. For example, to register a Database
Schema dependency identified by schema
:
$checks = $app->make(CollectsApplicationDependencyChecks::class); $checks->addDependencyCheck( 'schema', $app->make(\Shrink\Conductor\Laravel\Dependencies\DatabaseSchema::class) );
Supported Dependency Checks
Database Schema
Database Schema checks that the connected database is running a compatible version of the database schema. A database schema is compatible when every migration (on the filesystem) has been applied to the database.
Depends on a lcobucci/clock
implementation.
use Illuminate\Database\Migrations\Migrator; use Lcobucci\Clock\Clock; use Shrink\Conductor\Laravel\Dependencies\DatabaseSchema; new DatabaseSchema( $app->make(Migrator::class, 'migrator'), (string) $app->basePath('database/migrations'), $app->make(Clock::class) );
Development
Hooks
A pre-commit Git Hook is included for ensuring compliance with code requirements on commit, enable the Git Hook by running the following command:
dev:~$ git config core.hooksPath .github/hooks
License
Conductor: Laravel is open-sourced software licensed under the MIT license.