1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\ORM\Tools\Console; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Tools\Console as DBALConsole; |
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
9
|
|
|
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper; |
10
|
|
|
use PackageVersions\Versions; |
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Application; |
12
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Handles running the Console Tools inside Symfony Console context. |
16
|
|
|
*/ |
17
|
|
|
final class ConsoleRunner |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Create a Symfony Console HelperSet |
21
|
|
|
* |
22
|
|
|
* @param EntityManagerInterface $entityManager |
23
|
|
|
* |
24
|
|
|
* @return HelperSet |
25
|
|
|
*/ |
26
|
|
|
public static function createHelperSet(EntityManagerInterface $entityManager) : HelperSet |
27
|
|
|
{ |
28
|
|
|
return new HelperSet( |
29
|
|
|
[ |
30
|
|
|
'db' => new DBALConsole\Helper\ConnectionHelper($entityManager->getConnection()), |
31
|
|
|
'em' => new EntityManagerHelper($entityManager), |
32
|
|
|
] |
33
|
|
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Runs console with the given helper set. |
38
|
|
|
* |
39
|
|
|
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet |
40
|
|
|
* @param \Symfony\Component\Console\Command\Command[] $commands |
41
|
|
|
* |
42
|
|
|
* @return void |
43
|
|
|
*/ |
44
|
|
|
public static function run(HelperSet $helperSet, array $commands = []) : void |
45
|
|
|
{ |
46
|
|
|
$cli = self::createApplication($helperSet, $commands); |
47
|
|
|
$cli->run(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Creates a console application with the given helperset and |
52
|
|
|
* optional commands. |
53
|
|
|
* |
54
|
|
|
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet |
55
|
|
|
* @param array $commands |
56
|
|
|
* |
57
|
|
|
* @return \Symfony\Component\Console\Application |
58
|
|
|
* @throws \OutOfBoundsException |
59
|
|
|
*/ |
60
|
|
|
public static function createApplication(HelperSet $helperSet, array $commands = []) : Application |
61
|
|
|
{ |
62
|
|
|
$cli = new Application('Doctrine Command Line Interface', Versions::getVersion('doctrine/orm')); |
63
|
|
|
$cli->setCatchExceptions(true); |
64
|
|
|
$cli->setHelperSet($helperSet); |
65
|
|
|
self::addCommands($cli); |
66
|
|
|
$cli->addCommands($commands); |
67
|
|
|
|
68
|
|
|
return $cli; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
1 |
|
* @param Application $cli |
73
|
|
|
* |
74
|
1 |
|
* @return void |
75
|
1 |
|
*/ |
76
|
1 |
|
public static function addCommands(Application $cli) : void |
77
|
1 |
|
{ |
78
|
1 |
|
$cli->addCommands( |
79
|
|
|
[ |
80
|
1 |
|
// DBAL Commands |
81
|
|
|
new DBALConsole\Command\ImportCommand(), |
82
|
|
|
new DBALConsole\Command\ReservedWordsCommand(), |
83
|
|
|
new DBALConsole\Command\RunSqlCommand(), |
84
|
|
|
|
85
|
|
|
// ORM Commands |
86
|
|
|
new Command\ClearCache\CollectionRegionCommand(), |
87
|
|
|
new Command\ClearCache\EntityRegionCommand(), |
88
|
1 |
|
new Command\ClearCache\MetadataCommand(), |
89
|
|
|
new Command\ClearCache\QueryCommand(), |
90
|
1 |
|
new Command\ClearCache\QueryRegionCommand(), |
91
|
|
|
new Command\ClearCache\ResultCommand(), |
92
|
1 |
|
new Command\SchemaTool\CreateCommand(), |
93
|
1 |
|
new Command\SchemaTool\UpdateCommand(), |
94
|
|
|
new Command\SchemaTool\DropCommand(), |
95
|
|
|
new Command\EnsureProductionSettingsCommand(), |
96
|
1 |
|
new Command\GenerateRepositoriesCommand(), |
97
|
1 |
|
new Command\GenerateEntitiesCommand(), |
98
|
1 |
|
new Command\GenerateProxiesCommand(), |
99
|
1 |
|
new Command\ConvertMappingCommand(), |
100
|
1 |
|
new Command\RunDqlCommand(), |
101
|
1 |
|
new Command\ValidateSchemaCommand(), |
102
|
1 |
|
new Command\InfoCommand(), |
103
|
1 |
|
new Command\MappingDescribeCommand(), |
104
|
1 |
|
] |
105
|
1 |
|
); |
106
|
1 |
|
} |
107
|
1 |
|
|
108
|
1 |
|
public static function printCliConfigTemplate() : void |
109
|
1 |
|
{ |
110
|
1 |
|
echo <<<'HELP' |
111
|
|
|
You are missing a "cli-config.php" or "config/cli-config.php" file in your |
112
|
1 |
|
project, which is required to get the Doctrine Console working. You can use the |
113
|
|
|
following sample as a template: |
114
|
|
|
|
115
|
|
|
<?php |
116
|
|
|
use Doctrine\ORM\Tools\Console\ConsoleRunner; |
117
|
|
|
|
118
|
|
|
// replace with file to your own project bootstrap |
119
|
|
|
require_once 'bootstrap.php'; |
120
|
|
|
|
121
|
|
|
// replace with mechanism to retrieve EntityManager in your app |
122
|
|
|
$entityManager = GetEntityManager(); |
123
|
|
|
|
124
|
|
|
return ConsoleRunner::createHelperSet($entityManager); |
125
|
|
|
|
126
|
|
|
HELP; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
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