1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Laravel Zero. |
5
|
|
|
* |
6
|
|
|
* (c) Nuno Maduro <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LaravelZero\Framework\Commands\App; |
13
|
|
|
|
14
|
|
|
use LaravelZero\Framework\Components; |
15
|
|
|
use LaravelZero\Framework\Commands\Command; |
16
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* This is the Laravel Zero Framework Installer Command implementation. |
20
|
|
|
*/ |
21
|
|
|
class Installer extends Command |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
protected $signature = 'app:install {component? : The component name}'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritdoc} |
30
|
|
|
*/ |
31
|
|
|
protected $description = 'Installs a new component'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* The list of components installers. |
35
|
|
|
* |
36
|
|
|
* @var array |
37
|
|
|
*/ |
38
|
|
|
protected $components = [ |
39
|
|
|
'database' => Components\Database\Installer::class, |
40
|
|
|
'dotenv' => Components\Dotenv\Installer::class, |
41
|
|
|
'log' => Components\Log\Installer::class, |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
6 |
|
public function handle(): void |
48
|
|
|
{ |
49
|
6 |
|
$option = $this->argument('component') ?: $this->menu( |
|
|
|
|
50
|
|
|
'Laravel Zero - Component installer', |
51
|
|
|
[ |
52
|
|
|
'database' => 'Database - Laravel Eloquent', |
53
|
|
|
'log' => 'Log - Laravel Log component', |
54
|
|
|
'dotenv' => 'Dotenv - Loads environment variables from `.env`', |
55
|
|
|
] |
56
|
|
|
) |
57
|
|
|
->setForegroundColour('green') |
58
|
|
|
->setBackgroundColour('black') |
59
|
6 |
|
->open(); |
60
|
|
|
|
61
|
6 |
|
if ($option !== null && ! empty($this->components[$option])) { |
62
|
6 |
|
($command = $this->app[$this->components[$option]])->setLaravel($this->app); |
63
|
|
|
|
64
|
6 |
|
$this->info("Installing {$option} component..."); |
65
|
|
|
|
66
|
6 |
|
$command->run(new ArrayInput([]), $this->output); |
67
|
|
|
} |
68
|
6 |
|
} |
69
|
|
|
} |
70
|
|
|
|
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: