Skip to content

Commit 7ff5021

Browse files
Move loading .env files to bootstrap.php
1 parent 8f1a28f commit 7ff5021

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);

0 commit comments

Comments
 (0)