Merge pull request #491

This commit is contained in:
symfony-flex-server[bot]
2018-11-15 13:20:35 +00:00
committed by GitHub
29 changed files with 121 additions and 170 deletions
@@ -1,3 +1,4 @@
<?php
App\Kernel::bootstrapEnv('test');
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'test');
require dirname(__DIR__, 2).'/src/.bootstrap.php';
+2 -1
View File
@@ -1,7 +1,8 @@
{
"copy-from-recipe": {
"behat.yml.dist": "behat.yml.dist",
"features/": "features/"
"features/": "features/",
"src/": "%SRC_DIR%/"
},
"aliases": ["behat"],
"gitignore": ["behat.yml"]
+1
View File
@@ -0,0 +1 @@
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php
+2 -1
View File
@@ -1,4 +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
+1
View File
@@ -2,6 +2,7 @@
"copy-from-recipe": {
".env.test": ".env.test",
"phpunit.xml.dist": "phpunit.xml.dist",
"src/": "%SRC_DIR%/",
"tests/": "tests/"
},
"gitignore": [
+2 -1
View File
@@ -5,10 +5,11 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
bootstrap="src/.bootstrap.php"
>
<php>
<ini name="error_reporting" value="-1" />
<env name="APP_ENV" value="test" />
</php>
<testsuites>
+1
View File
@@ -0,0 +1 @@
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php
-5
View File
@@ -1,5 +0,0 @@
<?php
require dirname(__DIR__).'/vendor/autoload.php';
App\Kernel::bootstrapEnv('test');
+15 -4
View File
@@ -3,6 +3,7 @@
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;
set_time_limit(0);
@@ -10,11 +11,21 @@ set_time_limit(0);
require dirname(__DIR__).'/vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new \RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
Kernel::bootstrapCli($_SERVER['argv']);
Kernel::bootstrapEnv();
$input = new ArgvInput();
if (null !== $_ENV['APP_ENV'] = $input->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);
+2 -1
View File
@@ -1,6 +1,7 @@
{
"copy-from-recipe": {
"bin/": "%BIN_DIR%/"
"bin/": "%BIN_DIR%/",
"src/": "%SRC_DIR%/"
},
"aliases": ["cli"]
}
+1
View File
@@ -0,0 +1 @@
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php
+1
View File
@@ -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
@@ -4,9 +4,7 @@ use App\Kernel;
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);
@@ -0,0 +1,51 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
if (!array_key_exists('APP_ENV', $_SERVER)) {
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
}
if ('prod' !== $_SERVER['APP_ENV']) {
if (!class_exists(Dotenv::class)) {
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.');
}
$path = dirname(__DIR__).'/.env';
$dotenv = new Dotenv();
if (method_exists($dotenv, 'loadEnv')) {
$dotenv->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';
+1 -80
View File
@@ -6,7 +6,6 @@ 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;
@@ -30,7 +29,7 @@ class Kernel extends BaseKernel
{
$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 @@ class Kernel extends BaseKernel
$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);
}
}
}
@@ -4,9 +4,7 @@ use App\Kernel;
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);
@@ -0,0 +1,21 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
if (!array_key_exists('APP_ENV', $_SERVER)) {
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] ?? null;
}
if ('prod' !== $_SERVER['APP_ENV']) {
if (!class_exists(Dotenv::class)) {
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.');
}
(new Dotenv())->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';
+1 -28
View File
@@ -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 @@ class Kernel extends BaseKernel
{
$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 @@ class Kernel extends BaseKernel
$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';
}
}
+1 -2
View File
@@ -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
+3 -4
View File
@@ -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');
}
+1
View File
@@ -4,6 +4,7 @@
"bin/": "%BIN_DIR%/",
"config/": "%CONFIG_DIR%/",
"phpunit.xml.dist": "phpunit.xml.dist",
"src/": "%SRC_DIR%/",
"tests/": "tests/"
},
"gitignore": [
+2 -1
View File
@@ -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"
>
<php>
<ini name="error_reporting" value="-1" />
<env name="APP_ENV" value="test" />
</php>
<testsuites>
+1
View File
@@ -0,0 +1 @@
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php
+1 -2
View File
@@ -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
+3 -4
View File
@@ -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=');
}
+1
View File
@@ -3,6 +3,7 @@
".env.test": ".env.test",
"bin/": "%BIN_DIR%/",
"phpunit.xml.dist": "phpunit.xml.dist",
"src/": "%SRC_DIR%/",
"tests/": "tests/"
},
"gitignore": [
@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
+1
View File
@@ -0,0 +1 @@
../3.3/phpunit.xml.dist
+1
View File
@@ -0,0 +1 @@
../../../../symfony/framework-bundle/3.3/src/.bootstrap.php