diff --git a/behat/symfony2-extension/2.1/features/bootstrap/bootstrap.php b/behat/symfony2-extension/2.1/features/bootstrap/bootstrap.php index 371e1b2cf..97871bbdb 100644 --- a/behat/symfony2-extension/2.1/features/bootstrap/bootstrap.php +++ b/behat/symfony2-extension/2.1/features/bootstrap/bootstrap.php @@ -1,3 +1,4 @@ + diff --git a/phpunit/phpunit/4.7/src/.bootstrap.php b/phpunit/phpunit/4.7/src/.bootstrap.php new file mode 120000 index 000000000..02c7cfb74 --- /dev/null +++ b/phpunit/phpunit/4.7/src/.bootstrap.php @@ -0,0 +1 @@ +../../../../symfony/framework-bundle/3.3/src/.bootstrap.php \ No newline at end of file diff --git a/phpunit/phpunit/4.7/tests/.gitignore b/phpunit/phpunit/4.7/tests/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/phpunit/phpunit/4.7/tests/bootstrap.php b/phpunit/phpunit/4.7/tests/bootstrap.php deleted file mode 100644 index fec999bd0..000000000 --- a/phpunit/phpunit/4.7/tests/bootstrap.php +++ /dev/null @@ -1,5 +0,0 @@ -getParameterOption(['--env', '-e'], null, true)) { + putenv('APP_ENV='.$_ENV['APP_ENV']); + // force loading .env files when --env is defined + $_SERVER['APP_ENV'] = null; +} + +if ($input->hasParameterOption('--no-debug', true)) { + putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); +} + +require dirname(__DIR__).'/src/.bootstrap.php'; if ($_SERVER['APP_DEBUG']) { umask(0000); @@ -26,4 +37,4 @@ if ($_SERVER['APP_DEBUG']) { $kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']); $application = new Application($kernel); -$application->run(); +$application->run($input); diff --git a/symfony/console/3.3/manifest.json b/symfony/console/3.3/manifest.json index b0e9e1d41..66f423396 100644 --- a/symfony/console/3.3/manifest.json +++ b/symfony/console/3.3/manifest.json @@ -1,6 +1,7 @@ { "copy-from-recipe": { - "bin/": "%BIN_DIR%/" + "bin/": "%BIN_DIR%/", + "src/": "%SRC_DIR%/" }, "aliases": ["cli"] } diff --git a/symfony/console/3.3/src/.bootstrap.php b/symfony/console/3.3/src/.bootstrap.php new file mode 120000 index 000000000..02c7cfb74 --- /dev/null +++ b/symfony/console/3.3/src/.bootstrap.php @@ -0,0 +1 @@ +../../../../symfony/framework-bundle/3.3/src/.bootstrap.php \ No newline at end of file diff --git a/symfony/flex/1.0/.env b/symfony/flex/1.0/.env index 07ad02bb4..3e92b0d9b 100644 --- a/symfony/flex/1.0/.env +++ b/symfony/flex/1.0/.env @@ -1,4 +1,5 @@ # This file defines all environment variables that the application needs. +# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE. # Use ".env.local" for local overrides during development. # Use real environment variables when deploying to production. # https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration diff --git a/symfony/framework-bundle/3.3/public/index.php b/symfony/framework-bundle/3.3/public/index.php index c10bbd577..3f40a88b5 100644 --- a/symfony/framework-bundle/3.3/public/index.php +++ b/symfony/framework-bundle/3.3/public/index.php @@ -4,9 +4,7 @@ use Symfony\Component\Debug\Debug; use Symfony\Component\HttpFoundation\Request; -require dirname(__DIR__).'/vendor/autoload.php'; - -Kernel::bootstrapEnv(); +require dirname(__DIR__).'/src/.bootstrap.php'; if ($_SERVER['APP_DEBUG']) { umask(0000); diff --git a/symfony/framework-bundle/3.3/src/.bootstrap.php b/symfony/framework-bundle/3.3/src/.bootstrap.php new file mode 100644 index 000000000..8fc9ae973 --- /dev/null +++ b/symfony/framework-bundle/3.3/src/.bootstrap.php @@ -0,0 +1,51 @@ +loadEnv($path); + } else { + // fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added) + + if (file_exists($path) || !file_exists($p = "$path.dist")) { + $dotenv->load($path); + } else { + $dotenv->load($p); + } + + if (null === $env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) { + $dotenv->populate(array('APP_ENV' => $env = 'dev')); + } + + if ('test' !== $env && file_exists($p = "$path.local")) { + $dotenv->load($p); + $env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env; + } + + if (file_exists($p = "$path.$env")) { + $dotenv->load($p); + } + + if (file_exists($p = "$path.$env.local")) { + $dotenv->load($p); + } + } +} + +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: '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/framework-bundle/3.3/src/Kernel.php b/symfony/framework-bundle/3.3/src/Kernel.php index e552e52ef..edb95a089 100644 --- a/symfony/framework-bundle/3.3/src/Kernel.php +++ b/symfony/framework-bundle/3.3/src/Kernel.php @@ -6,7 +6,6 @@ use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\RouteCollectionBuilder; @@ -30,7 +29,7 @@ public function registerBundles() { $contents = require $this->getProjectDir().'/config/bundles.php'; foreach ($contents as $class => $envs) { - if (isset($envs['all']) || isset($envs[$this->environment])) { + if ($envs[$this->environment] ?? $envs['all'] ?? false) { yield new $class(); } } @@ -59,82 +58,4 @@ protected function configureRoutes(RouteCollectionBuilder $routes) $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); } - - public static function bootstrapCli(array &$argv) - { - // consume --env and --no-debug from the command line - - // when using symfony/console v4.2 or higher, this should - // be replaced by a call to Application::bootstrapEnv() - - for ($i = 0; $i < \count($argv) && '--' !== $v = $argv[$i]; ++$i) { - if ('--no-debug' === $v) { - putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0'); - $argvUnset[$i] = true; - break; - } - } - - for ($i = 0; $i < \count($argv) && '--' !== $v = $argv[$i]; ++$i) { - if (!$v || '-' !== $v[0] || !preg_match('/^-(?:-env(?:=|$)|e=?)(.*)$/D', $v, $v)) { - continue; - } - if (!empty($v[1]) || !empty($argv[1 + $i])) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = empty($v[1]) ? $argv[1 + $i] : $v[1]); - $argvUnset[$i] = $argvUnset[$i + empty($v[1])] = true; - } - break; - } - - if (!empty($argvUnset)) { - $argv = array_values(array_diff_key($argv, $argvUnset)); - } - } - - public static function bootstrapEnv($env = null) - { - if (null !== $env) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $env); - } - - if ('prod' !== $_SERVER['APP_ENV'] = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) { - if (!class_exists(Dotenv::class)) { - throw new \RuntimeException('The "APP_ENV" environment variable is not defined. You need to set it or run "composer require symfony/dotenv" to load it from a ".env" file.'); - } - - // when using symfony/dotenv v4.2 or higher, this call and the related methods - // below should be replaced by a call to the new Dotenv::loadEnv() method - self::loadEnv(new Dotenv(), \dirname(__DIR__).'/.env'); - } - - $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev'; - $_SERVER['APP_DEBUG'] = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : (isset($_ENV['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'; - } - - private static function loadEnv(Dotenv $dotenv, $path) - { - if (file_exists($path) || !file_exists($p = "$path.dist")) { - $dotenv->load($path); - } else { - $dotenv->load($p); - } - - if (null === $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) { - $dotenv->populate(array('APP_ENV' => $env = 'dev')); - } - - if ('test' !== $env && file_exists($p = "$path.local")) { - $dotenv->load($p); - $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : $env); - } - - if (file_exists($p = "$path.$env")) { - $dotenv->load($p); - } - - if (file_exists($p = "$path.$env.local")) { - $dotenv->load($p); - } - } } diff --git a/symfony/framework-bundle/4.2/public/index.php b/symfony/framework-bundle/4.2/public/index.php index c10bbd577..3f40a88b5 100644 --- a/symfony/framework-bundle/4.2/public/index.php +++ b/symfony/framework-bundle/4.2/public/index.php @@ -4,9 +4,7 @@ use Symfony\Component\Debug\Debug; use Symfony\Component\HttpFoundation\Request; -require dirname(__DIR__).'/vendor/autoload.php'; - -Kernel::bootstrapEnv(); +require dirname(__DIR__).'/src/.bootstrap.php'; if ($_SERVER['APP_DEBUG']) { umask(0000); diff --git a/symfony/framework-bundle/4.2/src/.bootstrap.php b/symfony/framework-bundle/4.2/src/.bootstrap.php new file mode 100644 index 000000000..95c1cd41a --- /dev/null +++ b/symfony/framework-bundle/4.2/src/.bootstrap.php @@ -0,0 +1,21 @@ +loadEnv(dirname(__DIR__).'/.env'); +} + +$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: '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/framework-bundle/4.2/src/Kernel.php b/symfony/framework-bundle/4.2/src/Kernel.php index 3a323b560..552eb0df2 100644 --- a/symfony/framework-bundle/4.2/src/Kernel.php +++ b/symfony/framework-bundle/4.2/src/Kernel.php @@ -2,12 +2,10 @@ namespace App; -use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\RouteCollectionBuilder; @@ -31,7 +29,7 @@ public function registerBundles() { $contents = require $this->getProjectDir().'/config/bundles.php'; foreach ($contents as $class => $envs) { - if (($envs['all'] ?? false) && ($envs[$this->environment] ?? true) || ($envs[$this->environment] ?? false)) { + if ($envs[$this->environment] ?? $envs['all'] ?? false) { yield new $class(); } } @@ -57,29 +55,4 @@ protected function configureRoutes(RouteCollectionBuilder $routes) $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); } - - public static function bootstrapCli(array &$argv) - { - // consume --env and --no-debug from the command line - Application::bootstrapEnv($argv); - } - - public static function bootstrapEnv(string $env = null) - { - if (null !== $env) { - putenv('APP_ENV='.$_SERVER['APP_ENV'] = $env); - } - - if ('prod' !== $_SERVER['APP_ENV'] = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) { - if (!class_exists(Dotenv::class)) { - throw new \RuntimeException('The "APP_ENV" environment variable is not defined. You need to set it or run "composer require symfony/dotenv" to load it from a ".env" file.'); - } - - (new Dotenv())->loadEnv(\dirname(__DIR__).'/.env'); - } - - $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?? $_SERVER['APP_ENV'] ?? '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/phpunit-bridge/3.3/.env.test b/symfony/phpunit-bridge/3.3/.env.test index 5ae9f7de6..bae86b3e8 100644 --- a/symfony/phpunit-bridge/3.3/.env.test +++ b/symfony/phpunit-bridge/3.3/.env.test @@ -1,6 +1,5 @@ # define your env variables for the test env here -KERNEL_CLASS=App\\Kernel +KERNEL_CLASS='App\Kernel' APP_SECRET='s$cretf0rt3st' SHELL_VERBOSITY=-1 SYMFONY_DEPRECATIONS_HELPER=999999 -SYMFONY_PHPUNIT_VERSION=6.5 diff --git a/symfony/phpunit-bridge/3.3/bin/phpunit b/symfony/phpunit-bridge/3.3/bin/phpunit index e4f3c26f4..0b79fd4a5 100755 --- a/symfony/phpunit-bridge/3.3/bin/phpunit +++ b/symfony/phpunit-bridge/3.3/bin/phpunit @@ -6,10 +6,9 @@ if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-php exit(1); } -$classLoader = require dirname(__DIR__).'/vendor/autoload.php'; -App\Kernel::bootstrapEnv('test'); -$classLoader->unregister(); - +if (false === getenv('SYMFONY_PHPUNIT_VERSION')) { + putenv('SYMFONY_PHPUNIT_VERSION=6.5'); +} if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) { putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml'); } diff --git a/symfony/phpunit-bridge/3.3/manifest.json b/symfony/phpunit-bridge/3.3/manifest.json index 6a0aab996..8a865563b 100644 --- a/symfony/phpunit-bridge/3.3/manifest.json +++ b/symfony/phpunit-bridge/3.3/manifest.json @@ -4,6 +4,7 @@ "bin/": "%BIN_DIR%/", "config/": "%CONFIG_DIR%/", "phpunit.xml.dist": "phpunit.xml.dist", + "src/": "%SRC_DIR%/", "tests/": "tests/" }, "gitignore": [ diff --git a/symfony/phpunit-bridge/3.3/phpunit.xml.dist b/symfony/phpunit-bridge/3.3/phpunit.xml.dist index e283e8dba..ecd288daf 100644 --- a/symfony/phpunit-bridge/3.3/phpunit.xml.dist +++ b/symfony/phpunit-bridge/3.3/phpunit.xml.dist @@ -5,10 +5,11 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd" backupGlobals="false" colors="true" - bootstrap="vendor/autoload.php" + bootstrap="src/.bootstrap.php" > + diff --git a/symfony/phpunit-bridge/3.3/src/.bootstrap.php b/symfony/phpunit-bridge/3.3/src/.bootstrap.php new file mode 120000 index 000000000..02c7cfb74 --- /dev/null +++ b/symfony/phpunit-bridge/3.3/src/.bootstrap.php @@ -0,0 +1 @@ +../../../../symfony/framework-bundle/3.3/src/.bootstrap.php \ No newline at end of file diff --git a/symfony/phpunit-bridge/4.1/.env.test b/symfony/phpunit-bridge/4.1/.env.test index 5ae9f7de6..bae86b3e8 100644 --- a/symfony/phpunit-bridge/4.1/.env.test +++ b/symfony/phpunit-bridge/4.1/.env.test @@ -1,6 +1,5 @@ # define your env variables for the test env here -KERNEL_CLASS=App\\Kernel +KERNEL_CLASS='App\Kernel' APP_SECRET='s$cretf0rt3st' SHELL_VERBOSITY=-1 SYMFONY_DEPRECATIONS_HELPER=999999 -SYMFONY_PHPUNIT_VERSION=6.5 diff --git a/symfony/phpunit-bridge/4.1/bin/phpunit b/symfony/phpunit-bridge/4.1/bin/phpunit index f28f65f80..cd7e32e71 100755 --- a/symfony/phpunit-bridge/4.1/bin/phpunit +++ b/symfony/phpunit-bridge/4.1/bin/phpunit @@ -6,10 +6,9 @@ if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-php exit(1); } -$classLoader = require dirname(__DIR__).'/vendor/autoload.php'; -App\Kernel::bootstrapEnv('test'); -$classLoader->unregister(); - +if (false === getenv('SYMFONY_PHPUNIT_VERSION')) { + putenv('SYMFONY_PHPUNIT_VERSION=6.5'); +} if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) { putenv('SYMFONY_PHPUNIT_REMOVE='); } diff --git a/symfony/phpunit-bridge/4.1/manifest.json b/symfony/phpunit-bridge/4.1/manifest.json index 01a2e0543..b28ff9ffc 100644 --- a/symfony/phpunit-bridge/4.1/manifest.json +++ b/symfony/phpunit-bridge/4.1/manifest.json @@ -3,6 +3,7 @@ ".env.test": ".env.test", "bin/": "%BIN_DIR%/", "phpunit.xml.dist": "phpunit.xml.dist", + "src/": "%SRC_DIR%/", "tests/": "tests/" }, "gitignore": [ diff --git a/symfony/phpunit-bridge/4.1/phpunit.xml.dist b/symfony/phpunit-bridge/4.1/phpunit.xml.dist deleted file mode 100644 index e283e8dba..000000000 --- a/symfony/phpunit-bridge/4.1/phpunit.xml.dist +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - tests - - - - - - src - - - - - - - diff --git a/symfony/phpunit-bridge/4.1/phpunit.xml.dist b/symfony/phpunit-bridge/4.1/phpunit.xml.dist new file mode 120000 index 000000000..29458d485 --- /dev/null +++ b/symfony/phpunit-bridge/4.1/phpunit.xml.dist @@ -0,0 +1 @@ +../3.3/phpunit.xml.dist \ No newline at end of file diff --git a/symfony/phpunit-bridge/4.1/src/.bootstrap.php b/symfony/phpunit-bridge/4.1/src/.bootstrap.php new file mode 120000 index 000000000..02c7cfb74 --- /dev/null +++ b/symfony/phpunit-bridge/4.1/src/.bootstrap.php @@ -0,0 +1 @@ +../../../../symfony/framework-bundle/3.3/src/.bootstrap.php \ No newline at end of file