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?
- Install the library with composer
- Enable Conductor with the optional Service Provider
- Define your application's runtime dependencies
↓ Jump to Dependencies available for Laravel
dev:~$ composer require shrink/conductor-laravel
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,
// ...
];
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)
);
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)
);
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
Conductor: Laravel is open-sourced software licensed under the MIT license.