Skip to content

[1.x] Adds fortify:install Artisan command #524

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 4 commits into from
Mar 8, 2024
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
52 changes: 52 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Laravel\Fortify\Console;

use Illuminate\Console\Command;
use Illuminate\Support\ServiceProvider;
use Laravel\Fortify\FortifyServiceProvider;

class InstallCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'fortify:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Install all of the Fortify resources';

/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$this->callSilent('vendor:publish', [
'--provider' => FortifyServiceProvider::class,
]);

$this->registerFortifyServiceProvider();

$this->components->info('Fortify scaffolding installed successfully.');
}

/**
* Register the Fortify service provider in the application configuration file.
*/
protected function registerFortifyServiceProvider(): void
{
if (! method_exists(ServiceProvider::class, 'addProviderToBootstrapFile')) {
return;
}

ServiceProvider::addProviderToBootstrapFile(\App\Providers\FortifyServiceProvider::class);
}
}
13 changes: 13 additions & 0 deletions src/FortifyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public function boot()
{
$this->configurePublishing();
$this->configureRoutes();
$this->registerCommands();
}

/**
Expand Down Expand Up @@ -161,4 +162,16 @@ protected function configureRoutes()
});
}
}

/**
* Register the package's commands.
*/
protected function registerCommands(): void
{
if ($this->app->runningInConsole()) {
$this->commands([
Console\InstallCommand::class,
]);
}
}
}