Skip to content

Add support for laravel 6.x #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
}
],
"require": {
"php": ">=5.5",
"illuminate/config": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*",
"illuminate/filesystem": "5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*"
"php": ">=7.2",
"illuminate/config": "^6.0",
"illuminate/filesystem": "^6.0"
},
"autoload": {
"psr-4": {
Expand Down
80 changes: 28 additions & 52 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function boot()

if ($this->app->runningInConsole()) {
$this->commands([
'command.deploy-commands.install',
'command.deploy-commands.make',
'command.deploy-commands.run',
'command.deploy-commands.mark'
InstallCommand::class,
MakeCommand::class,
RunCommand::class,
MarkCommand::class,
]);
}
}
Expand All @@ -43,91 +43,74 @@ public function register()
);

$this->registerRepository();

$this->registerRunner();

$this->registerCreator();

if ($this->app->runningInConsole()) {
// Register commands
$this->registerMigrateInstallCommand();

$this->registerMakeCommand();

$this->registerRunCommand();

$this->registerMarkCommand();
}
}

/**
* Register the migration repository service.
*
* @return void
*/
protected function registerRepository()
protected function registerRepository(): void
{
$this->app->singleton('deploy-commands.repository', function ($app) {
$table = $app['config']['deploy-commands.table'];
$this->app->singleton(DatabaseMigrationRepository::class, function ($app) {
$table = config('deploy-commands.table');

return new DatabaseMigrationRepository($app['db'], $table);
});
}

/**
* Register the migrator service.
*
* @return void
*/
protected function registerRunner()
protected function registerRunner(): void
{
// The migrator is responsible for actually running and rollback the migration
// files in the application. We'll pass in our database connection resolver
// so the migrator can resolve any of these connections when it needs to.
$this->app->singleton('deploy-commands.runner', function ($app) {
$repository = $app['deploy-commands.repository'];
$this->app->singleton(CommandRunner::class, function ($app) {
$repository = $app->make(DatabaseMigrationRepository::class);

return new CommandRunner($app, $repository, $app['db'], $app['files']);
});
}

/**
* Register the migration creator.
*
* @return void
*/
protected function registerCreator()
protected function registerCreator(): void
{
$this->app->singleton('deploy-commands.creator', function ($app) {
$this->app->singleton(CommandCreator::class, function ($app) {
return new CommandCreator($app['files']);
});
}

/**
* Register the command.
*
* @return void
*/
protected function registerMigrateInstallCommand()
protected function registerMigrateInstallCommand(): void
{
$this->app->singleton('command.deploy-commands.install', function ($app) {
return new InstallCommand($app['deploy-commands.repository']);
$this->app->singleton(InstallCommand::class, function ($app) {
return new InstallCommand($app->make(DatabaseMigrationRepository::class));
});
}

/**
* Register the command.
*
* @return void
*/
protected function registerMakeCommand()
protected function registerMakeCommand(): void
{
$this->app->singleton('command.deploy-commands.make', function ($app) {
$this->app->singleton(MakeCommand::class, function ($app) {
// Once we have the migration creator registered, we will create the command
// and inject the creator. The creator is responsible for the actual file
// creation of the migrations, and may be extended by these developers.
$creator = $app['deploy-commands.creator'];

$creator = $app->make(CommandCreator::class);
$composer = $app['composer'];

return new MakeCommand($creator, $composer);
Expand All @@ -136,40 +119,33 @@ protected function registerMakeCommand()

/**
* Register the command.
*
* @return void
*/
protected function registerRunCommand()
protected function registerRunCommand(): void
{
$this->app->singleton('command.deploy-commands.run', function ($app) {
return new RunCommand($app['deploy-commands.runner']);
$this->app->singleton(RunCommand::class, function ($app) {
return new RunCommand($app->make(CommandRunner::class));
});
}

/**
* Register the command.
*
* @return void
*/
protected function registerMarkCommand()
protected function registerMarkCommand(): void
{
$this->app->singleton('command.deploy-commands.mark', function ($app) {
return new MarkCommand($app['deploy-commands.runner']);
$this->app->singleton(MarkCommand::class, function ($app) {
return new MarkCommand($app->make(CommandRunner::class));
});
}


/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
public function provides(): array
{
return [
'deploy-commands.repository',
'deploy-commands.runner',
'deploy-commands.creator',
DatabaseMigrationRepository::class,
CommandRunner::class,
CommandCreator::class,
];
}
}