From 22ff9fe53f433b66a4bc9f7e4ac0e0ea7f2e2695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 5 Sep 2023 14:17:00 +0200 Subject: [PATCH] Upgrade recipes: symfony/console --- bin/console | 39 +++++++-------------------------------- composer.json | 3 ++- config/bootstrap.php | 23 ----------------------- symfony.lock | 11 +++++------ 4 files changed, 14 insertions(+), 62 deletions(-) delete mode 100644 config/bootstrap.php diff --git a/bin/console b/bin/console index 5de0e1c..c933dc5 100755 --- a/bin/console +++ b/bin/console @@ -3,40 +3,15 @@ use App\Kernel; use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\ErrorHandler\Debug; -if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { - echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL; +if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { + throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); } -set_time_limit(0); +require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; -require dirname(__DIR__).'/vendor/autoload.php'; +return function (array $context) { + $kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); -if (!class_exists(Application::class)) { - throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.'); -} - -$input = new ArgvInput(); -if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env); -} - -if ($input->hasParameterOption('--no-debug', true)) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); -} - -require dirname(__DIR__).'/config/bootstrap.php'; - -if ($_SERVER['APP_DEBUG']) { - umask(0000); - - if (class_exists(Debug::class)) { - Debug::enable(); - } -} - -$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); -$application = new Application($kernel); -$application->run($input); + return new Application($kernel); +}; diff --git a/composer.json b/composer.json index 038b924..4a2612b 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ "phpoffice/phpword": "^0.18.2", "phpstan/phpstan": "^1.0", "spomky-labs/base64url": "^2.0", - "twig/string-extra": "^3.3" + "twig/string-extra": "^3.3", + "symfony/runtime": "^5.4" }, "require-dev": { "fakerphp/faker": "^1.13", diff --git a/config/bootstrap.php b/config/bootstrap.php deleted file mode 100644 index 55560fb..0000000 --- a/config/bootstrap.php +++ /dev/null @@ -1,23 +0,0 @@ -=1.2) -if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) { - (new Dotenv(false))->populate($env); -} else { - // load all the .env files - (new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env'); -} - -$_SERVER += $_ENV; -$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev'; -$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV']; -$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0'; diff --git a/symfony.lock b/symfony.lock index f2612fd..5fee9c9 100644 --- a/symfony.lock +++ b/symfony.lock @@ -456,16 +456,15 @@ "version": "v5.1.3" }, "symfony/console": { - "version": "4.4", + "version": "5.4", "recipe": { "repo": "github.com/symfony/recipes", - "branch": "master", - "version": "4.4", - "ref": "ea8c0eda34fda57e7d5cd8cbd889e2a387e3472c" + "branch": "main", + "version": "5.3", + "ref": "da0c8be8157600ad34f10ff0c9cc91232522e047" }, "files": [ - "bin/console", - "config/bootstrap.php" + "bin/console" ] }, "symfony/css-selector": {