Skip to content

Commit 4469293

Browse files
committed
Updated to the latest recipe changes
1 parent 4a61d28 commit 4469293

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

.php_cs.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ $finder = PhpCsFixer\Finder::create()
1515
->exclude('var')
1616
->exclude('public/bundles')
1717
->exclude('public/build')
18+
// exclude files generated by Symfony Flex recipes
19+
->notPath('bin/console')
20+
->notPath('public/index.php')
1821
;
1922

2023
return PhpCsFixer\Config::create()

bin/console

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ if (!class_exists(Application::class)) {
1616
}
1717

1818
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+
}
1922
(new Dotenv())->load(__DIR__.'/../.env');
2023
}
2124

2225
$input = new ArgvInput();
23-
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev');
24-
$debug = ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption(['--no-debug', '']);
26+
$env = $input->getParameterOption(['--env', '-e'], $_SERVER['APP_ENV'] ?? 'dev', true);
27+
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env)) && !$input->hasParameterOption('--no-debug', true);
2528

2629
if ($debug) {
2730
umask(0000);

config/packages/twig_extensions.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ services:
44
autowire: true
55
autoconfigure: true
66

7-
# needed for the 'localizeddate' Twig filter
8-
Twig\Extensions\IntlExtension: ~
7+
#Twig\Extensions\ArrayExtension: ~
8+
#Twig\Extensions\DateExtension: ~
9+
Twig\Extensions\IntlExtension: ~ # needed for the 'localizeddate' filter
10+
#Twig\Extensions\TextExtension: ~

public/index.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
<?php
22

3-
/*
4-
* This file is part of the Symfony package.
5-
*
6-
* (c) Fabien Potencier <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
11-
123
use App\Kernel;
134
use Symfony\Component\Debug\Debug;
145
use Symfony\Component\Dotenv\Dotenv;
@@ -18,18 +9,30 @@
189

1910
// The check is to ensure we don't use .env in production
2011
if (!isset($_SERVER['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+
}
2115
(new Dotenv())->load(__DIR__.'/../.env');
2216
}
2317

24-
if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) {
18+
$env = $_SERVER['APP_ENV'] ?? 'dev';
19+
$debug = (bool) ($_SERVER['APP_DEBUG'] ?? ('prod' !== $env));
20+
21+
if ($debug) {
2522
umask(0000);
2623

2724
Debug::enable();
2825
}
2926

30-
// Request::setTrustedProxies(['0.0.0.0/0'], Request::HEADER_FORWARDED);
27+
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
28+
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
29+
}
30+
31+
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
32+
Request::setTrustedHosts(explode(',', $trustedHosts));
33+
}
3134

32-
$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev')));
35+
$kernel = new Kernel($env, $debug);
3336
$request = Request::createFromGlobals();
3437
$response = $kernel->handle($request);
3538
$response->send();

0 commit comments

Comments
 (0)