-
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathInstallCommand.php
77 lines (62 loc) · 2.25 KB
/
InstallCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
declare(strict_types=1);
/**
* This file is part of Laravel Zero.
*
* (c) Nuno Maduro <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace LaravelZero\Framework\Commands;
use LaravelZero\Framework\Components;
use LaravelZero\Framework\Components\AbstractInstaller;
use Symfony\Component\Console\Input\ArrayInput;
final class InstallCommand extends Command
{
/**
* {@inheritdoc}
*/
protected $signature = 'app:install {component? : The component name}';
/**
* {@inheritdoc}
*/
protected $description = 'Install optional components';
/**
* The list of components installers.
*
* @var array
*/
private $componentInstallers = [
'console-dusk' => Components\ConsoleDusk\Installer::class,
'database' => Components\Database\Installer::class,
'dotenv' => Components\Dotenv\Installer::class,
'http' => Components\Http\Installer::class,
'log' => Components\Log\Installer::class,
'menu' => Components\Menu\Installer::class,
'queue' => Components\Queue\Installer::class,
'redis' => Components\Redis\Installer::class,
'self-update' => Components\Updater\Installer::class,
'view' => Components\View\Installer::class,
];
public function handle()
{
$title = 'Laravel Zero - Component installer';
$choices = [];
foreach ($this->componentInstallers as $name => $componentClass) {
$choices[$name] = $this->app->make($componentClass)->getDescription();
}
if (! $option = $this->argument('component')) {
$option = $this->choice($title, $choices);
}
// @phpstan-ignore notIdentical.alwaysTrue
if ($option !== null && ! empty($this->componentInstallers[$option])) {
/** @var AbstractInstaller $command */
$command = $this->app[$this->componentInstallers[$option]];
$command->setLaravel($this->app);
$command->setApplication($this->getApplication());
$this->info("Installing {$option} component...");
$command->run(new ArrayInput([]), $this->output);
}
}
}