Skip to content

Commit 86e2b67

Browse files
author
symfony-flex-server[bot]
authored
Merge pull request #491
2 parents 7c88acc + 7ff5021 commit 86e2b67

File tree

29 files changed

+121
-170
lines changed

29 files changed

+121
-170
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<?php
22

3-
App\Kernel::bootstrapEnv('test');
3+
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'test');
4+
require dirname(__DIR__, 2).'/src/.bootstrap.php';

behat/symfony2-extension/2.1/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"copy-from-recipe": {
33
"behat.yml.dist": "behat.yml.dist",
4-
"features/": "features/"
4+
"features/": "features/",
5+
"src/": "%SRC_DIR%/"
56
},
67
"aliases": ["behat"],
78
"gitignore": ["behat.yml"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php

phpunit/phpunit/4.7/.env.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# define your env variables for the test env here
2-
KERNEL_CLASS=App\\Kernel
2+
KERNEL_CLASS='App\Kernel'
33
APP_SECRET='s$cretf0rt3st'
44
SHELL_VERBOSITY=-1
5+
SYMFONY_DEPRECATIONS_HELPER=999999

phpunit/phpunit/4.7/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"copy-from-recipe": {
33
".env.test": ".env.test",
44
"phpunit.xml.dist": "phpunit.xml.dist",
5+
"src/": "%SRC_DIR%/",
56
"tests/": "tests/"
67
},
78
"gitignore": [

phpunit/phpunit/4.7/phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
66
backupGlobals="false"
77
colors="true"
8-
bootstrap="tests/bootstrap.php"
8+
bootstrap="src/.bootstrap.php"
99
>
1010
<php>
1111
<ini name="error_reporting" value="-1" />
12+
<env name="APP_ENV" value="test" />
1213
</php>
1314

1415
<testsuites>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php

phpunit/phpunit/4.7/tests/.gitignore

Whitespace-only changes.

phpunit/phpunit/4.7/tests/bootstrap.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

symfony/console/3.3/bin/console

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,29 @@
33

44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
6+
use Symfony\Component\Console\Input\ArgvInput;
67
use Symfony\Component\Debug\Debug;
78

89
set_time_limit(0);
910

1011
require dirname(__DIR__).'/vendor/autoload.php';
1112

1213
if (!class_exists(Application::class)) {
13-
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
14+
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
1415
}
1516

16-
Kernel::bootstrapCli($_SERVER['argv']);
17-
Kernel::bootstrapEnv();
17+
$input = new ArgvInput();
18+
if (null !== $_ENV['APP_ENV'] = $input->getParameterOption(['--env', '-e'], null, true)) {
19+
putenv('APP_ENV='.$_ENV['APP_ENV']);
20+
// force loading .env files when --env is defined
21+
$_SERVER['APP_ENV'] = null;
22+
}
23+
24+
if ($input->hasParameterOption('--no-debug', true)) {
25+
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
26+
}
27+
28+
require dirname(__DIR__).'/src/.bootstrap.php';
1829

1930
if ($_SERVER['APP_DEBUG']) {
2031
umask(0000);
@@ -26,4 +37,4 @@ if ($_SERVER['APP_DEBUG']) {
2637

2738
$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
2839
$application = new Application($kernel);
29-
$application->run();
40+
$application->run($input);

symfony/console/3.3/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"copy-from-recipe": {
3-
"bin/": "%BIN_DIR%/"
3+
"bin/": "%BIN_DIR%/",
4+
"src/": "%SRC_DIR%/"
45
},
56
"aliases": ["cli"]
67
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php

symfony/flex/1.0/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This file defines all environment variables that the application needs.
2+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE.
23
# Use ".env.local" for local overrides during development.
34
# Use real environment variables when deploying to production.
45
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

symfony/framework-bundle/3.3/public/index.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
use Symfony\Component\Debug\Debug;
55
use Symfony\Component\HttpFoundation\Request;
66

7-
require dirname(__DIR__).'/vendor/autoload.php';
8-
9-
Kernel::bootstrapEnv();
7+
require dirname(__DIR__).'/src/.bootstrap.php';
108

119
if ($_SERVER['APP_DEBUG']) {
1210
umask(0000);
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
use Symfony\Component\Dotenv\Dotenv;
4+
5+
require dirname(__DIR__).'/vendor/autoload.php';
6+
7+
if (!array_key_exists('APP_ENV', $_SERVER)) {
8+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
9+
}
10+
11+
if ('prod' !== $_SERVER['APP_ENV']) {
12+
if (!class_exists(Dotenv::class)) {
13+
throw new RuntimeException('The "APP_ENV" environment variable is not set to "prod". Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
14+
}
15+
16+
$path = dirname(__DIR__).'/.env';
17+
$dotenv = new Dotenv();
18+
19+
if (method_exists($dotenv, 'loadEnv')) {
20+
$dotenv->loadEnv($path);
21+
} else {
22+
// fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)
23+
24+
if (file_exists($path) || !file_exists($p = "$path.dist")) {
25+
$dotenv->load($path);
26+
} else {
27+
$dotenv->load($p);
28+
}
29+
30+
if (null === $env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) {
31+
$dotenv->populate(array('APP_ENV' => $env = 'dev'));
32+
}
33+
34+
if ('test' !== $env && file_exists($p = "$path.local")) {
35+
$dotenv->load($p);
36+
$env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env;
37+
}
38+
39+
if (file_exists($p = "$path.$env")) {
40+
$dotenv->load($p);
41+
}
42+
43+
if (file_exists($p = "$path.$env.local")) {
44+
$dotenv->load($p);
45+
}
46+
}
47+
}
48+
49+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';
50+
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
51+
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

symfony/framework-bundle/3.3/src/Kernel.php

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Symfony\Component\Config\Loader\LoaderInterface;
77
use Symfony\Component\Config\Resource\FileResource;
88
use Symfony\Component\DependencyInjection\ContainerBuilder;
9-
use Symfony\Component\Dotenv\Dotenv;
109
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
1110
use Symfony\Component\Routing\RouteCollectionBuilder;
1211

@@ -30,7 +29,7 @@ public function registerBundles()
3029
{
3130
$contents = require $this->getProjectDir().'/config/bundles.php';
3231
foreach ($contents as $class => $envs) {
33-
if (isset($envs['all']) || isset($envs[$this->environment])) {
32+
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
3433
yield new $class();
3534
}
3635
}
@@ -59,82 +58,4 @@ protected function configureRoutes(RouteCollectionBuilder $routes)
5958
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
6059
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
6160
}
62-
63-
public static function bootstrapCli(array &$argv)
64-
{
65-
// consume --env and --no-debug from the command line
66-
67-
// when using symfony/console v4.2 or higher, this should
68-
// be replaced by a call to Application::bootstrapEnv()
69-
70-
for ($i = 0; $i < \count($argv) && '--' !== $v = $argv[$i]; ++$i) {
71-
if ('--no-debug' === $v) {
72-
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
73-
$argvUnset[$i] = true;
74-
break;
75-
}
76-
}
77-
78-
for ($i = 0; $i < \count($argv) && '--' !== $v = $argv[$i]; ++$i) {
79-
if (!$v || '-' !== $v[0] || !preg_match('/^-(?:-env(?:=|$)|e=?)(.*)$/D', $v, $v)) {
80-
continue;
81-
}
82-
if (!empty($v[1]) || !empty($argv[1 + $i])) {
83-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = empty($v[1]) ? $argv[1 + $i] : $v[1]);
84-
$argvUnset[$i] = $argvUnset[$i + empty($v[1])] = true;
85-
}
86-
break;
87-
}
88-
89-
if (!empty($argvUnset)) {
90-
$argv = array_values(array_diff_key($argv, $argvUnset));
91-
}
92-
}
93-
94-
public static function bootstrapEnv($env = null)
95-
{
96-
if (null !== $env) {
97-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $env);
98-
}
99-
100-
if ('prod' !== $_SERVER['APP_ENV'] = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) {
101-
if (!class_exists(Dotenv::class)) {
102-
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.');
103-
}
104-
105-
// when using symfony/dotenv v4.2 or higher, this call and the related methods
106-
// below should be replaced by a call to the new Dotenv::loadEnv() method
107-
self::loadEnv(new Dotenv(), \dirname(__DIR__).'/.env');
108-
}
109-
110-
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : 'dev';
111-
$_SERVER['APP_DEBUG'] = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : (isset($_ENV['APP_DEBUG']) ? $_ENV['APP_DEBUG'] : 'prod' !== $_SERVER['APP_ENV']);
112-
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
113-
}
114-
115-
private static function loadEnv(Dotenv $dotenv, $path)
116-
{
117-
if (file_exists($path) || !file_exists($p = "$path.dist")) {
118-
$dotenv->load($path);
119-
} else {
120-
$dotenv->load($p);
121-
}
122-
123-
if (null === $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) {
124-
$dotenv->populate(array('APP_ENV' => $env = 'dev'));
125-
}
126-
127-
if ('test' !== $env && file_exists($p = "$path.local")) {
128-
$dotenv->load($p);
129-
$env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : $env);
130-
}
131-
132-
if (file_exists($p = "$path.$env")) {
133-
$dotenv->load($p);
134-
}
135-
136-
if (file_exists($p = "$path.$env.local")) {
137-
$dotenv->load($p);
138-
}
139-
}
14061
}

symfony/framework-bundle/4.2/public/index.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
use Symfony\Component\Debug\Debug;
55
use Symfony\Component\HttpFoundation\Request;
66

7-
require dirname(__DIR__).'/vendor/autoload.php';
8-
9-
Kernel::bootstrapEnv();
7+
require dirname(__DIR__).'/src/.bootstrap.php';
108

119
if ($_SERVER['APP_DEBUG']) {
1210
umask(0000);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use Symfony\Component\Dotenv\Dotenv;
4+
5+
require dirname(__DIR__).'/vendor/autoload.php';
6+
7+
if (!array_key_exists('APP_ENV', $_SERVER)) {
8+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
9+
}
10+
11+
if ('prod' !== $_SERVER['APP_ENV']) {
12+
if (!class_exists(Dotenv::class)) {
13+
throw new RuntimeException('The "APP_ENV" environment variable is not set to "prod". Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
14+
}
15+
16+
(new Dotenv())->loadEnv(dirname(__DIR__).'/.env');
17+
}
18+
19+
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?: $_ENV['APP_ENV'] ?: 'dev';
20+
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
21+
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

symfony/framework-bundle/4.2/src/Kernel.php

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
namespace App;
44

5-
use Symfony\Bundle\FrameworkBundle\Console\Application;
65
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
76
use Symfony\Component\Config\Loader\LoaderInterface;
87
use Symfony\Component\Config\Resource\FileResource;
98
use Symfony\Component\DependencyInjection\ContainerBuilder;
10-
use Symfony\Component\Dotenv\Dotenv;
119
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
1210
use Symfony\Component\Routing\RouteCollectionBuilder;
1311

@@ -31,7 +29,7 @@ public function registerBundles()
3129
{
3230
$contents = require $this->getProjectDir().'/config/bundles.php';
3331
foreach ($contents as $class => $envs) {
34-
if (($envs['all'] ?? false) && ($envs[$this->environment] ?? true) || ($envs[$this->environment] ?? false)) {
32+
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
3533
yield new $class();
3634
}
3735
}
@@ -57,29 +55,4 @@ protected function configureRoutes(RouteCollectionBuilder $routes)
5755
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
5856
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
5957
}
60-
61-
public static function bootstrapCli(array &$argv)
62-
{
63-
// consume --env and --no-debug from the command line
64-
Application::bootstrapEnv($argv);
65-
}
66-
67-
public static function bootstrapEnv(string $env = null)
68-
{
69-
if (null !== $env) {
70-
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $env);
71-
}
72-
73-
if ('prod' !== $_SERVER['APP_ENV'] = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) {
74-
if (!class_exists(Dotenv::class)) {
75-
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.');
76-
}
77-
78-
(new Dotenv())->loadEnv(\dirname(__DIR__).'/.env');
79-
}
80-
81-
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['APP_ENV'] ?? $_SERVER['APP_ENV'] ?? 'dev';
82-
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
83-
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
84-
}
8558
}

symfony/phpunit-bridge/3.3/.env.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# define your env variables for the test env here
2-
KERNEL_CLASS=App\\Kernel
2+
KERNEL_CLASS='App\Kernel'
33
APP_SECRET='s$cretf0rt3st'
44
SHELL_VERBOSITY=-1
55
SYMFONY_DEPRECATIONS_HELPER=999999
6-
SYMFONY_PHPUNIT_VERSION=6.5

symfony/phpunit-bridge/3.3/bin/phpunit

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ if (!file_exists(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-php
66
exit(1);
77
}
88

9-
$classLoader = require dirname(__DIR__).'/vendor/autoload.php';
10-
App\Kernel::bootstrapEnv('test');
11-
$classLoader->unregister();
12-
9+
if (false === getenv('SYMFONY_PHPUNIT_VERSION')) {
10+
putenv('SYMFONY_PHPUNIT_VERSION=6.5');
11+
}
1312
if (false === getenv('SYMFONY_PHPUNIT_REMOVE')) {
1413
putenv('SYMFONY_PHPUNIT_REMOVE=symfony/yaml');
1514
}

symfony/phpunit-bridge/3.3/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"bin/": "%BIN_DIR%/",
55
"config/": "%CONFIG_DIR%/",
66
"phpunit.xml.dist": "phpunit.xml.dist",
7+
"src/": "%SRC_DIR%/",
78
"tests/": "tests/"
89
},
910
"gitignore": [

0 commit comments

Comments
 (0)