Merged in upgrade (pull request #26)
Upgrading DotEnv files and other dependencies.
This commit is contained in:
commit
8a0a99f5b1
|
@ -3,7 +3,7 @@
|
||||||
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
|
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
|
||||||
|
|
||||||
###> symfony/framework-bundle ###
|
###> symfony/framework-bundle ###
|
||||||
APP_ENV=dev
|
APP_ENV=prod
|
||||||
APP_SECRET=xxx
|
APP_SECRET=xxx
|
||||||
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
|
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
|
||||||
#TRUSTED_HOSTS=localhost,example.com
|
#TRUSTED_HOSTS=localhost,example.com
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,7 +1,9 @@
|
||||||
/.idea/
|
/.idea/
|
||||||
|
|
||||||
###> symfony/framework-bundle ###
|
###> symfony/framework-bundle ###
|
||||||
/.env
|
/.env.local
|
||||||
|
/.env.local.php
|
||||||
|
/.env.*.local
|
||||||
/public/bundles/
|
/public/bundles/
|
||||||
/var/
|
/var/
|
||||||
/vendor/
|
/vendor/
|
||||||
|
|
31
bin/console
31
bin/console
|
@ -5,28 +5,31 @@ use App\Kernel;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\Debug\Debug;
|
use Symfony\Component\Debug\Debug;
|
||||||
use Symfony\Component\Dotenv\Dotenv;
|
|
||||||
|
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
|
||||||
|
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
require __DIR__.'/../vendor/autoload.php';
|
require dirname(__DIR__).'/vendor/autoload.php';
|
||||||
|
|
||||||
if (!class_exists(Application::class)) {
|
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.');
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($_SERVER['APP_ENV'])) {
|
|
||||||
if (!class_exists(Dotenv::class)) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
(new Dotenv())->load(__DIR__.'/../.env');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$input = new ArgvInput();
|
$input = new ArgvInput();
|
||||||
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
|
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
|
||||||
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
|
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
|
||||||
|
}
|
||||||
|
|
||||||
if ($debug) {
|
if ($input->hasParameterOption('--no-debug', true)) {
|
||||||
|
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
require dirname(__DIR__).'/config/bootstrap.php';
|
||||||
|
|
||||||
|
if ($_SERVER['APP_DEBUG']) {
|
||||||
umask(0000);
|
umask(0000);
|
||||||
|
|
||||||
if (class_exists(Debug::class)) {
|
if (class_exists(Debug::class)) {
|
||||||
|
@ -34,6 +37,6 @@ if ($debug) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = new Kernel($env, $debug);
|
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
||||||
$application = new Application($kernel);
|
$application = new Application($kernel);
|
||||||
$application->run($input);
|
$application->run($input);
|
||||||
|
|
44
composer.lock
generated
44
composer.lock
generated
|
@ -1869,42 +1869,42 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sensio/framework-extra-bundle",
|
"name": "sensio/framework-extra-bundle",
|
||||||
"version": "v5.3.1",
|
"version": "v5.4.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
|
"url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git",
|
||||||
"reference": "5f75c4658b03301cba17baa15a840b57b72b4262"
|
"reference": "585f4b3a1c54f24d1a8431c729fc8f5acca20c8a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/5f75c4658b03301cba17baa15a840b57b72b4262",
|
"url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/585f4b3a1c54f24d1a8431c729fc8f5acca20c8a",
|
||||||
"reference": "5f75c4658b03301cba17baa15a840b57b72b4262",
|
"reference": "585f4b3a1c54f24d1a8431c729fc8f5acca20c8a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"doctrine/annotations": "^1.0",
|
"doctrine/annotations": "^1.0",
|
||||||
"doctrine/persistence": "^1.0",
|
"doctrine/persistence": "^1.0",
|
||||||
"php": ">=7.1.3",
|
"php": ">=7.1.3",
|
||||||
"symfony/config": "^3.4|^4.2",
|
"symfony/config": "^3.4|^4.3",
|
||||||
"symfony/dependency-injection": "^3.4|^4.2",
|
"symfony/dependency-injection": "^3.4|^4.3",
|
||||||
"symfony/framework-bundle": "^3.4|^4.2",
|
"symfony/framework-bundle": "^3.4|^4.3",
|
||||||
"symfony/http-kernel": "^3.4|^4.2"
|
"symfony/http-kernel": "^3.4|^4.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/doctrine-bundle": "^1.6",
|
"doctrine/doctrine-bundle": "^1.6",
|
||||||
"doctrine/orm": "^2.5",
|
"doctrine/orm": "^2.5",
|
||||||
"nyholm/psr7": "^1.1",
|
"nyholm/psr7": "^1.1",
|
||||||
"symfony/browser-kit": "^3.4|^4.2",
|
"symfony/browser-kit": "^3.4|^4.3",
|
||||||
"symfony/dom-crawler": "^3.4|^4.2",
|
"symfony/dom-crawler": "^3.4|^4.3",
|
||||||
"symfony/expression-language": "^3.4|^4.2",
|
"symfony/expression-language": "^3.4|^4.3",
|
||||||
"symfony/finder": "^3.4|^4.2",
|
"symfony/finder": "^3.4|^4.3",
|
||||||
"symfony/monolog-bridge": "^3.0|^4.0",
|
"symfony/monolog-bridge": "^3.0|^4.0",
|
||||||
"symfony/monolog-bundle": "^3.2",
|
"symfony/monolog-bundle": "^3.2",
|
||||||
"symfony/phpunit-bridge": "^3.4.19|^4.1.8",
|
"symfony/phpunit-bridge": "^3.4.19|^4.1.8",
|
||||||
"symfony/psr-http-message-bridge": "^1.1",
|
"symfony/psr-http-message-bridge": "^1.1",
|
||||||
"symfony/security-bundle": "^3.4|^4.2",
|
"symfony/security-bundle": "^3.4|^4.3",
|
||||||
"symfony/twig-bundle": "^3.4|^4.2",
|
"symfony/twig-bundle": "^3.4|^4.3",
|
||||||
"symfony/yaml": "^3.4|^4.2",
|
"symfony/yaml": "^3.4|^4.3",
|
||||||
"twig/twig": "~1.12|~2.0"
|
"twig/twig": "~1.12|~2.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
|
@ -1915,7 +1915,7 @@
|
||||||
"type": "symfony-bundle",
|
"type": "symfony-bundle",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "5.3.x-dev"
|
"dev-master": "5.4.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -1938,7 +1938,7 @@
|
||||||
"annotations",
|
"annotations",
|
||||||
"controllers"
|
"controllers"
|
||||||
],
|
],
|
||||||
"time": "2019-04-10T06:00:20+00:00"
|
"time": "2019-07-08T08:31:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sentry/sentry",
|
"name": "sentry/sentry",
|
||||||
|
@ -2796,16 +2796,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/flex",
|
"name": "symfony/flex",
|
||||||
"version": "v1.4.1",
|
"version": "v1.4.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/flex.git",
|
"url": "https://github.com/symfony/flex.git",
|
||||||
"reference": "a388cacccf6e3c5e5a395e020c5aa05849ea4ccc"
|
"reference": "4b5d25a5538e2dc37ff84645fe7498a9a04947b3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/flex/zipball/a388cacccf6e3c5e5a395e020c5aa05849ea4ccc",
|
"url": "https://api.github.com/repos/symfony/flex/zipball/4b5d25a5538e2dc37ff84645fe7498a9a04947b3",
|
||||||
"reference": "a388cacccf6e3c5e5a395e020c5aa05849ea4ccc",
|
"reference": "4b5d25a5538e2dc37ff84645fe7498a9a04947b3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -2841,7 +2841,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Composer plugin for Symfony",
|
"description": "Composer plugin for Symfony",
|
||||||
"time": "2019-06-28T18:01:09+00:00"
|
"time": "2019-07-12T06:29:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/form",
|
"name": "symfony/form",
|
||||||
|
|
19
config/bootstrap.php
Normal file
19
config/bootstrap.php
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
require dirname(__DIR__).'/vendor/autoload.php';
|
||||||
|
// Load cached env vars if the .env.local.php file exists
|
||||||
|
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
|
||||||
|
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
|
||||||
|
foreach ($env as $k => $v) {
|
||||||
|
$_ENV[$k] = $_ENV[$k] ?? (isset($_SERVER[$k]) && 0 !== strpos($k, 'HTTP_') ? $_SERVER[$k] : $v);
|
||||||
|
}
|
||||||
|
} elseif (!class_exists(Dotenv::class)) {
|
||||||
|
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
|
||||||
|
} else {
|
||||||
|
// load all the .env files
|
||||||
|
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
|
||||||
|
}
|
||||||
|
$_SERVER += $_ENV;
|
||||||
|
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: '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';
|
|
@ -2,37 +2,25 @@
|
||||||
|
|
||||||
use App\Kernel;
|
use App\Kernel;
|
||||||
use Symfony\Component\Debug\Debug;
|
use Symfony\Component\Debug\Debug;
|
||||||
use Symfony\Component\Dotenv\Dotenv;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
require __DIR__.'/../vendor/autoload.php';
|
require dirname(__DIR__).'/config/bootstrap.php';
|
||||||
|
|
||||||
// The check is to ensure we don't use .env in production
|
if ($_SERVER['APP_DEBUG']) {
|
||||||
if (!isset($_SERVER['APP_ENV'])) {
|
|
||||||
if (!class_exists(Dotenv::class)) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
(new Dotenv())->load(__DIR__.'/../.env');
|
|
||||||
}
|
|
||||||
|
|
||||||
$env = $_SERVER['APP_ENV'] ?? 'dev';
|
|
||||||
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
|
|
||||||
|
|
||||||
if ($debug) {
|
|
||||||
umask(0000);
|
umask(0000);
|
||||||
|
|
||||||
Debug::enable();
|
Debug::enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
|
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
|
||||||
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
|
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
|
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
|
||||||
Request::setTrustedHosts(explode(',', $trustedHosts));
|
Request::setTrustedHosts([$trustedHosts]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = new Kernel($env, $debug);
|
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
|
||||||
$request = Request::createFromGlobals();
|
$request = Request::createFromGlobals();
|
||||||
$response = $kernel->handle($request);
|
$response = $kernel->handle($request);
|
||||||
$response->send();
|
$response->send();
|
||||||
|
|
Loading…
Reference in a new issue