Skip to content

Commit 3074f22

Browse files
authored
Merge pull request #74 from GhentCDH/refactor/scripts
chore: update console/scripts
2 parents 6739320 + 4122a43 commit 3074f22

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

app/bin/console

+8-39
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,16 @@
11
#!/usr/bin/env php
22
<?php
3+
// bin/console
34

45
use App\Kernel;
56
use Symfony\Bundle\FrameworkBundle\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
7-
use Symfony\Component\Dotenv\Dotenv;
8-
use Symfony\Component\ErrorHandler\Debug;
97

10-
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
11-
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
12-
}
8+
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
139

14-
set_time_limit(0);
10+
return function (array $context): Application {
11+
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
1512

16-
require dirname(__DIR__).'/vendor/autoload.php';
17-
18-
if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
19-
throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
20-
}
21-
22-
$input = new ArgvInput();
23-
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
24-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
25-
}
26-
27-
if ($input->hasParameterOption('--no-debug', true)) {
28-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
29-
}
30-
31-
if ( file_exists(dirname(__DIR__).'/.env') ) {
32-
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
33-
} else {
34-
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
35-
}
36-
37-
if ($_SERVER['APP_DEBUG']) {
38-
umask(0000);
39-
40-
if (class_exists(Debug::class)) {
41-
Debug::enable();
42-
}
43-
}
44-
45-
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
46-
$application = new Application($kernel);
47-
$application->run($input);
13+
// returning an "Application" makes the Runtime run a Console
14+
// application instead of the HTTP Kernel
15+
return new Application($kernel);
16+
};

app/scripts/migrate.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
use Rector\Config\RectorConfig;
5+
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
6+
use Rector\Php80\ValueObject\AnnotationToAttribute;
7+
8+
return static function (RectorConfig $rectorConfig): void {
9+
// Paths for Rector to act upon
10+
$rectorConfig->paths([
11+
// __DIR__ . '/../config',
12+
// __DIR__ . '/../public',
13+
__DIR__ . '/../src/Controller',
14+
]);
15+
16+
17+
// Additional configuration (Rector rules) go here
18+
$rectorConfig->sets([
19+
\Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
20+
\Rector\Symfony\Set\SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
21+
\Rector\Symfony\Set\SensiolabsSetList::ANNOTATIONS_TO_ATTRIBUTES,
22+
]);
23+
24+
25+
$rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
26+
new AnnotationToAttribute(\Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity::class),
27+
new AnnotationToAttribute(\Ibericode\Vat\Bundle\Validator\Constraints\VatNumber::class),
28+
]);
29+
};

app/scripts/reindex.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
cd /app
2-
bin/console app:elasticsearch:index charter
3-
bin/console app:elasticsearch:index tradition
2+
bin/console app:elasticsearch:index charter $1
3+
bin/console app:elasticsearch:index tradition $1

0 commit comments

Comments
 (0)