Skip to content

Commit b34e672

Browse files
[1.x] Adds fortify:install Artisan command (#524)
* Adds `fortify:install` Artisan command * Apply fixes from StyleCI * Removes unused import * Fixes static analysis --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent 29cdcaf commit b34e672

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

src/Console/InstallCommand.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace Laravel\Fortify\Console;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\ServiceProvider;
7+
use Laravel\Fortify\FortifyServiceProvider;
8+
9+
class InstallCommand extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'fortify:install';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Install all of the Fortify resources';
24+
25+
/**
26+
* Execute the console command.
27+
*
28+
* @return void
29+
*/
30+
public function handle()
31+
{
32+
$this->callSilent('vendor:publish', [
33+
'--provider' => FortifyServiceProvider::class,
34+
]);
35+
36+
$this->registerFortifyServiceProvider();
37+
38+
$this->components->info('Fortify scaffolding installed successfully.');
39+
}
40+
41+
/**
42+
* Register the Fortify service provider in the application configuration file.
43+
*/
44+
protected function registerFortifyServiceProvider(): void
45+
{
46+
if (! method_exists(ServiceProvider::class, 'addProviderToBootstrapFile')) {
47+
return;
48+
}
49+
50+
ServiceProvider::addProviderToBootstrapFile(\App\Providers\FortifyServiceProvider::class);
51+
}
52+
}

src/FortifyServiceProvider.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public function boot()
113113
{
114114
$this->configurePublishing();
115115
$this->configureRoutes();
116+
$this->registerCommands();
116117
}
117118

118119
/**
@@ -161,4 +162,16 @@ protected function configureRoutes()
161162
});
162163
}
163164
}
165+
166+
/**
167+
* Register the package's commands.
168+
*/
169+
protected function registerCommands(): void
170+
{
171+
if ($this->app->runningInConsole()) {
172+
$this->commands([
173+
Console\InstallCommand::class,
174+
]);
175+
}
176+
}
164177
}

0 commit comments

Comments
 (0)