Updated recipe for symfony/framework-bundle.

This commit is contained in:
Jan Böhmer 2020-05-31 19:56:50 +02:00
parent 38028fcfc5
commit 16a2e23c51
3 changed files with 18 additions and 64 deletions

View file

@ -1,10 +1,13 @@
<?php <?php
use App\Kernel; use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php'; require dirname(__DIR__).'/vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
if ($_SERVER['APP_DEBUG']) { if ($_SERVER['APP_DEBUG']) {
umask(0000); umask(0000);

View file

@ -1,76 +1,28 @@
<?php <?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace App; namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
class Kernel extends BaseKernel class Kernel extends BaseKernel
{ {
use MicroKernelTrait; use MicroKernelTrait;
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; protected function configureContainer(ContainerConfigurator $container): void
public function registerBundles(): iterable
{ {
$contents = require $this->getProjectDir().'/config/bundles.php'; $container->import('../config/{packages}/*.yaml');
foreach ($contents as $class => $envs) { $container->import('../config/{packages}/'.$this->environment.'/*.yaml');
if ($envs[$this->environment] ?? $envs['all'] ?? false) { $container->import('../config/{services}.yaml');
yield new $class(); $container->import('../config/{services}_'.$this->environment.'.yaml');
}
}
} }
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');
$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.'/parameters.yaml');
$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');
} }
} }

View file

@ -558,15 +558,14 @@
"version": "v4.2.3" "version": "v4.2.3"
}, },
"symfony/framework-bundle": { "symfony/framework-bundle": {
"version": "4.4", "version": "5.1",
"recipe": { "recipe": {
"repo": "github.com/symfony/recipes", "repo": "github.com/symfony/recipes",
"branch": "master", "branch": "master",
"version": "4.4", "version": "5.1",
"ref": "36d3075b2b8e0c4de0e82356a86e4c4a4eb6681b" "ref": "37b4ec59eda3eb89705f21a0da7231862495ce0a"
}, },
"files": [ "files": [
"./config/bootstrap.php",
"./config/packages/cache.yaml", "./config/packages/cache.yaml",
"./config/packages/framework.yaml", "./config/packages/framework.yaml",
"./config/packages/test/framework.yaml", "./config/packages/test/framework.yaml",