|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of web-stack |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
declare(strict_types=1); |
|
11
|
|
|
|
|
12
|
|
|
namespace Slick\WebStack\Infrastructure\Console; |
|
13
|
|
|
|
|
14
|
|
|
use Composer\Autoload\ClassLoader; |
|
15
|
|
|
use Exception; |
|
16
|
|
|
use JsonException; |
|
17
|
|
|
use Slick\Configuration\ConfigurationInterface; |
|
18
|
|
|
use Slick\ModuleApi\Infrastructure\Console\ConsoleModuleInterface; |
|
19
|
|
|
use Slick\WebStack\ConsoleModule; |
|
20
|
|
|
use Slick\WebStack\DispatcherModule; |
|
21
|
|
|
use Slick\WebStack\FrontControllerModule; |
|
22
|
|
|
use Slick\WebStack\Infrastructure\AbstractApplication; |
|
23
|
|
|
use Slick\WebStack\Infrastructure\ApplicationSettingsInterface; |
|
|
|
|
|
|
24
|
|
|
use Slick\WebStack\Infrastructure\ComposerParser; |
|
25
|
|
|
use Symfony\Component\Console\Application; |
|
26
|
|
|
use function Slick\ModuleApi\constantValue; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* ConsoleApplication |
|
30
|
|
|
* |
|
31
|
|
|
* @package Slick\WebStack\Infrastructure\Console |
|
32
|
|
|
*/ |
|
33
|
|
|
final class ConsoleApplication extends AbstractApplication |
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
|
|
private ?Application $commandLine = null; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct(string $rootPath, ?ClassLoader $classLoader = null) |
|
39
|
|
|
{ |
|
40
|
|
|
parent::__construct($rootPath, $classLoader); |
|
41
|
|
|
$this->modules[] = new ConsoleModule(); |
|
42
|
|
|
$this->modules[] = new FrontControllerModule(); |
|
43
|
|
|
$this->modules[] = new DispatcherModule(); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @throws JsonException |
|
49
|
|
|
* @throws Exception |
|
50
|
|
|
*/ |
|
51
|
|
|
public function run(): null |
|
52
|
|
|
{ |
|
53
|
|
|
$container = $this->prepareContainer(); |
|
54
|
|
|
$commandsDir = $container->get(ConfigurationInterface::class)->get('console.commands_dir'); |
|
55
|
|
|
|
|
56
|
|
|
$loader = new ConsoleCommandLoader($container, APP_ROOT . $commandsDir); |
|
57
|
|
|
$cli = $this->commandLine(); |
|
58
|
|
|
|
|
59
|
|
|
$cli->setCatchExceptions(true); |
|
60
|
|
|
$cli->setCommandLoader($loader); |
|
61
|
|
|
|
|
62
|
|
|
foreach ($this->modules as $module) { |
|
63
|
|
|
if ($module instanceof ConsoleModuleInterface) { |
|
64
|
|
|
$module->configureConsole($cli, $container); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$cli->run(); |
|
69
|
|
|
return null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @throws JsonException |
|
74
|
|
|
*/ |
|
75
|
|
|
public function commandLine(): Application |
|
76
|
|
|
{ |
|
77
|
|
|
if (null === $this->commandLine) { |
|
78
|
|
|
$this->commandLine = $this->createCommandLine(); |
|
79
|
|
|
} |
|
80
|
|
|
return $this->commandLine; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function useCommandLine(?Application $commandLine): void |
|
84
|
|
|
{ |
|
85
|
|
|
$this->commandLine = $commandLine; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return Application |
|
90
|
|
|
* @throws JsonException |
|
91
|
|
|
*/ |
|
92
|
|
|
public function createCommandLine(): Application |
|
93
|
|
|
{ |
|
94
|
|
|
$composerParser = new ComposerParser(APP_ROOT . '/composer.json'); |
|
95
|
|
|
|
|
96
|
|
|
return new Application( |
|
97
|
|
|
constantValue('APP_NAME', $composerParser->appName()), |
|
98
|
|
|
constantValue('APP_VERSION', $composerParser->version()) |
|
99
|
|
|
); |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths