From f55236b948e208a5266ff3c2863f61cf33f55256 Mon Sep 17 00:00:00 2001
From: Franck J <45272552+ScytAl3@users.noreply.github.com>
Date: Fri, 4 Sep 2020 10:22:47 +0200
Subject: [PATCH] Update recipes
---
.env | 2 +-
bin/console | 7 +++--
config/packages/routing.yaml | 4 +++
config/packages/security.yaml | 3 +-
phpunit.xml.dist | 2 +-
public/index.php | 5 +++-
src/Kernel.php | 54 ++++++++++++-----------------------
symfony.lock | 28 +++++++++---------
8 files changed, 48 insertions(+), 57 deletions(-)
diff --git a/.env b/.env
index e8fc967..690893d 100644
--- a/.env
+++ b/.env
@@ -15,7 +15,7 @@
###> symfony/framework-bundle ###
APP_ENV=dev
-APP_SECRET=7d0b48c45661885c1b4557476348e13a
+APP_SECRET=06f72aa2f514c19322858fca514c9e45
#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$'
###< symfony/framework-bundle ###
diff --git a/bin/console b/bin/console
index 5de0e1c..8fe9d49 100644
--- a/bin/console
+++ b/bin/console
@@ -4,6 +4,7 @@
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
+use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug;
if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
@@ -14,8 +15,8 @@ set_time_limit(0);
require dirname(__DIR__).'/vendor/autoload.php';
-if (!class_exists(Application::class)) {
- throw new LogicException('You need to add "symfony/framework-bundle" as a Composer dependency.');
+if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
+ throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
}
$input = new ArgvInput();
@@ -27,7 +28,7 @@ if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
-require dirname(__DIR__).'/config/bootstrap.php';
+(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
if ($_SERVER['APP_DEBUG']) {
umask(0000);
diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml
index 7e97762..b45c1ce 100644
--- a/config/packages/routing.yaml
+++ b/config/packages/routing.yaml
@@ -1,3 +1,7 @@
framework:
router:
utf8: true
+
+ # Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
+ # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
+ #default_uri: http://localhost
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 811681e..0e4cf3d 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -7,7 +7,8 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
- anonymous: lazy
+ anonymous: true
+ lazy: true
provider: users_in_memory
# activate different ways to authenticate
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 516e4e2..2cee1b9 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -16,7 +16,7 @@
-
+
diff --git a/public/index.php b/public/index.php
index 0e30370..3f8b90e 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,10 +1,13 @@
bootEnv(dirname(__DIR__).'/.env');
if ($_SERVER['APP_DEBUG']) {
umask(0000);
diff --git a/src/Kernel.php b/src/Kernel.php
index 1cd0572..b016861 100644
--- a/src/Kernel.php
+++ b/src/Kernel.php
@@ -3,52 +3,36 @@
namespace App;
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\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
-use Symfony\Component\Routing\RouteCollectionBuilder;
+use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
- private const CONFIG_EXTS = '.{php,xml,yaml,yml}';
-
- public function registerBundles(): iterable
+ protected function configureContainer(ContainerConfigurator $container): void
{
- $contents = require $this->getProjectDir().'/config/bundles.php';
- foreach ($contents as $class => $envs) {
- if ($envs[$this->environment] ?? $envs['all'] ?? false) {
- yield new $class();
- }
+ $container->import('../config/{packages}/*.yaml');
+ $container->import('../config/{packages}/'.$this->environment.'/*.yaml');
+
+ if (is_file(\dirname(__DIR__).'/config/services.yaml')) {
+ $container->import('../config/{services}.yaml');
+ $container->import('../config/{services}_'.$this->environment.'.yaml');
+ } elseif (is_file($path = \dirname(__DIR__).'/config/services.php')) {
+ (require $path)($container->withPath($path), $this);
}
}
- public function getProjectDir(): string
+ protected function configureRoutes(RoutingConfigurator $routes): void
{
- return \dirname(__DIR__);
- }
+ $routes->import('../config/{routes}/'.$this->environment.'/*.yaml');
+ $routes->import('../config/{routes}/*.yaml');
- protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
- {
- $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php'));
- $container->setParameter('container.dumper.inline_class_loader', \PHP_VERSION_ID < 70400 || $this->debug);
- $container->setParameter('container.dumper.inline_factories', true);
- $confDir = $this->getProjectDir().'/config';
-
- $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
- $loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
- $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
- $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob');
- }
-
- protected function configureRoutes(RouteCollectionBuilder $routes): void
- {
- $confDir = $this->getProjectDir().'/config';
-
- $routes->import($confDir.'/{routes}/'.$this->environment.'/*'.self::CONFIG_EXTS, '/', 'glob');
- $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob');
- $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
+ if (is_file(\dirname(__DIR__).'/config/routes.yaml')) {
+ $routes->import('../config/{routes}.yaml');
+ } elseif (is_file($path = \dirname(__DIR__).'/config/routes.php')) {
+ (require $path)($routes->withPath($path), $this);
+ }
}
}
diff --git a/symfony.lock b/symfony.lock
index 1da9d89..5db18ab 100644
--- a/symfony.lock
+++ b/symfony.lock
@@ -181,16 +181,15 @@
"version": "v5.0.7"
},
"symfony/console": {
- "version": "4.4",
+ "version": "5.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
- "version": "4.4",
- "ref": "ea8c0eda34fda57e7d5cd8cbd889e2a387e3472c"
+ "version": "5.1",
+ "ref": "c6d02bdfba9da13c22157520e32a602dbee8a75c"
},
"files": [
- "./bin/console",
- "./config/bootstrap.php"
+ "./bin/console"
]
},
"symfony/css-selector": {
@@ -260,15 +259,14 @@
"version": "v5.0.7"
},
"symfony/framework-bundle": {
- "version": "4.4",
+ "version": "5.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
- "version": "4.4",
- "ref": "af2e2efad553bc959a0c61d9185e33ca9eec5c99"
+ "version": "5.1",
+ "ref": "e1b2770f2404d8307450a49cabfc3b2ff3184792"
},
"files": [
- "./config/bootstrap.php",
"./config/packages/cache.yaml",
"./config/packages/framework.yaml",
"./config/packages/test/framework.yaml",
@@ -403,12 +401,12 @@
"version": "v5.0.7"
},
"symfony/routing": {
- "version": "4.2",
+ "version": "5.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
- "version": "4.2",
- "ref": "683dcb08707ba8d41b7e34adb0344bfd68d248a7"
+ "version": "5.1",
+ "ref": "b4f3e7c95e38b606eef467e8a42a8408fc460c43"
},
"files": [
"./config/packages/prod/routing.yaml",
@@ -417,12 +415,12 @@
]
},
"symfony/security-bundle": {
- "version": "4.4",
+ "version": "5.1",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
- "version": "4.4",
- "ref": "7b4408dc203049666fe23fabed23cbadc6d8440f"
+ "version": "5.1",
+ "ref": "0a4bae19389d3b9cba1ca0102e3b2bccea724603"
},
"files": [
"./config/packages/security.yaml"