Skip to content

Commit d2599a1

Browse files
author
symfony-flex-server[bot]
authored
Merge pull request #481
2 parents 5b3ce90 + 95bb543 commit d2599a1

File tree

22 files changed

+157
-90
lines changed

22 files changed

+157
-90
lines changed
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
<?php
22

3-
use Symfony\Component\Dotenv\Dotenv;
4-
5-
// The check is to ensure we don't use .env in production
6-
if (!isset($_SERVER['APP_ENV'])) {
7-
if (!class_exists(Dotenv::class)) {
8-
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
9-
}
10-
(new Dotenv())->load(__DIR__.'/../../.env');
11-
}
3+
App\Kernel::bootstrapEnv('test');

phpunit/phpunit/4.7/.env.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# define your env variables for the test env here
2+
KERNEL_CLASS=App\\Kernel
3+
APP_SECRET='s$cretf0rt3st'
4+
SHELL_VERBOSITY=-1

phpunit/phpunit/4.7/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"copy-from-recipe": {
3+
".env.test": ".env.test",
34
"phpunit.xml.dist": "phpunit.xml.dist",
45
"tests/": "tests/"
56
},

phpunit/phpunit/4.7/phpunit.xml.dist

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22

33
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.7/phpunit.xsd"
66
backupGlobals="false"
77
colors="true"
8-
bootstrap="vendor/autoload.php"
8+
bootstrap="tests/bootstrap.php"
99
>
1010
<php>
1111
<ini name="error_reporting" value="-1" />
12-
<env name="KERNEL_CLASS" value="App\Kernel" />
13-
<env name="APP_ENV" value="test" />
14-
<env name="APP_DEBUG" value="1" />
15-
<env name="APP_SECRET" value="s$cretf0rt3st" />
16-
<env name="SHELL_VERBOSITY" value="-1" />
17-
<!-- define your env variables for the test env here -->
1812
</php>
1913

2014
<testsuites>

phpunit/phpunit/4.7/tests/.gitignore

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
require dirname(__DIR__).'/vendor/autoload.php';
4+
5+
App\Kernel::bootstrapEnv('test');

symfony/console/3.3/bin/console

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,27 @@
33

44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
6-
use Symfony\Component\Console\Input\ArgvInput;
76
use Symfony\Component\Debug\Debug;
8-
use Symfony\Component\Dotenv\Dotenv;
97

108
set_time_limit(0);
119

12-
require __DIR__.'/../vendor/autoload.php';
10+
require dirname(__DIR__).'/vendor/autoload.php';
1311

1412
if (!class_exists(Application::class)) {
1513
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
1614
}
1715

18-
if (!isset($_SERVER['APP_ENV'])) {
19-
if (!class_exists(Dotenv::class)) {
20-
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
21-
}
22-
(new Dotenv())->load(__DIR__.'/../.env');
23-
}
24-
25-
$input = new ArgvInput();
26-
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
27-
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
16+
Kernel::bootstrapCli($_SERVER['argv']);
17+
Kernel::bootstrapEnv();
2818

29-
if ($debug) {
19+
if ($_SERVER['APP_DEBUG']) {
3020
umask(0000);
3121

3222
if (class_exists(Debug::class)) {
3323
Debug::enable();
3424
}
3525
}
3626

37-
$kernel = new Kernel($env, $debug);
27+
$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
3828
$application = new Application($kernel);
39-
$application->run($input);
29+
$application->run();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file is a "template" of which env vars need to be defined for your application
2-
# Copy this file to .env file for development, create environment variables when deploying to production
2+
# Override the variables you want in .env.local for development, create environment variables when deploying to production
33
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

symfony/flex/1.0/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"copy-from-recipe": {
3-
".env.dist": ".env.dist"
3+
".env": ".env"
44
}
55
}

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,13 @@
22

33
use App\Kernel;
44
use Symfony\Component\Debug\Debug;
5-
use Symfony\Component\Dotenv\Dotenv;
65
use Symfony\Component\HttpFoundation\Request;
76

8-
require __DIR__.'/../vendor/autoload.php';
7+
require dirname(__DIR__).'/vendor/autoload.php';
98

10-
// The check is to ensure we don't use .env in production
11-
if (!isset($_SERVER['APP_ENV']) && !isset($_ENV['APP_ENV'])) {
12-
if (!class_exists(Dotenv::class)) {
13-
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
14-
}
15-
(new Dotenv())->load(__DIR__.'/../.env');
16-
}
17-
18-
$env = $_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'dev';
19-
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? ('prod' !== $env));
9+
Kernel::bootstrapEnv();
2010

21-
if ($debug) {
11+
if ($_SERVER['APP_DEBUG']) {
2212
umask(0000);
2313

2414
Debug::enable();
@@ -32,7 +22,7 @@
3222
Request::setTrustedHosts(explode(',', $trustedHosts));
3323
}
3424

35-
$kernel = new Kernel($env, $debug);
25+
$kernel = new Kernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
3626
$request = Request::createFromGlobals();
3727
$response = $kernel->handle($request);
3828
$response->send();

0 commit comments

Comments
 (0)