-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up the test application, use symfony/runtime
- Loading branch information
Showing
5 changed files
with
7 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
<?php | ||
|
||
if (file_exists(dirname(__DIR__).'/var/cache/prod/srcApp_KernelProdContainer.preload.php')) { | ||
require dirname(__DIR__).'/var/cache/prod/srcApp_KernelProdContainer.preload.php'; | ||
} | ||
|
||
if (file_exists(dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php')) { | ||
require dirname(__DIR__).'/var/cache/prod/App_KernelProdContainer.preload.php'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,9 @@ | ||
<?php | ||
|
||
use App\Kernel; | ||
use Symfony\Component\ErrorHandler\Debug; | ||
use Symfony\Component\ErrorHandler\DebugClassLoader; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
require dirname(__DIR__).'/config/bootstrap.php'; | ||
require_once dirname(__DIR__).'/vendor/autoload_runtime.php'; | ||
|
||
if ($_SERVER['APP_DEBUG']) { | ||
umask(0000); | ||
|
||
Debug::enable(); | ||
DebugClassLoader::disable(); | ||
} | ||
|
||
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) { | ||
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST); | ||
} | ||
|
||
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) { | ||
Request::setTrustedHosts([$trustedHosts]); | ||
} | ||
|
||
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']); | ||
$request = Request::createFromGlobals(); | ||
$response = $kernel->handle($request); | ||
$response->send(); | ||
$kernel->terminate($request, $response); | ||
return function (array $context) { | ||
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel as BaseKernel; | ||
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; | ||
use function is_dir; | ||
|
||
class Kernel extends BaseKernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
private const CONFIG_EXTS = '.{php,xml,yaml,yml}'; | ||
|
||
public function getCacheDir(): string | ||
{ | ||
return $this->getProjectDir().'/var/cache/'.$this->environment; | ||
} | ||
|
||
public function getLogDir(): string | ||
{ | ||
return $this->getProjectDir().'/var/log'; | ||
} | ||
|
||
/** | ||
* @return iterable<object> | ||
*/ | ||
public function registerBundles(): iterable | ||
{ | ||
$contents = require $this->getProjectDir().'/config/bundles.php'; | ||
foreach ($contents as $class => $envs) { | ||
if (!isset($envs['all']) && !isset($envs[$this->environment])) { | ||
continue; | ||
} | ||
|
||
yield new $class(); | ||
} | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void | ||
{ | ||
$container->setParameter('container.autowiring.strict_mode', true); | ||
$container->setParameter('container.dumper.inline_class_loader', true); | ||
$confDir = $this->getProjectDir().'/config'; | ||
$loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob'); | ||
if (is_dir($confDir.'/packages/'.$this->environment)) { | ||
$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(RoutingConfigurator $routes): void | ||
{ | ||
$confDir = $this->getProjectDir().'/config'; | ||
if (is_dir($confDir.'/routes/')) { | ||
$routes->import($confDir.'/routes/*'.self::CONFIG_EXTS); | ||
} | ||
|
||
if (is_dir($confDir.'/routes/'.$this->environment)) { | ||
$routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS); | ||
} | ||
|
||
$routes->import($confDir.'/routes'.self::CONFIG_EXTS); | ||
} | ||
} |