symfony-util / controller-using-templating-http-foundation
Controller which renders a template and returns a response (HttpFoundation)
dev-master / 7.0.x-dev
2019-02-27 23:56 UTC
Requires
- php: ^7.0
- symfony/http-foundation: ^2.0 || ^3.0 || ^4.0
- symfony/templating: ^2.0 || ^3.0 || ^4.0
Requires (Dev)
- symfony-util/coding-standards-fixer: ^5.4.0@alpha
- symfony/twig-bridge: ^2.0 || ^3.0 || ^4.0
- symfony/var-dumper: ^2.0 || ^3.0 || ^4.0
- twig/twig: ^1.0 || ^2.0
Suggests
- symfony-util/controller-using-templating-http-foundation-http-kernel: To use the right dependencies to be able to call the provided controller from Symfony (HttpKernel)
This package is auto-updated.
Last update: 2025-03-01 00:11:49 UTC
README
Controller which renders a template and returns a response (HttpFoundation)
TODO
- Test more than one Symfony version!
EngineAsArgumentController
- Uses Engine as controller argument for easier configuration with Symfony 3.3
- Because Twig was not found in autoconfig as a constructor argument
- http://symfony.com/doc/current/controller.html#fetching-services-as-controller-arguments
- constructor tested only with default value
Composer configuration for use in Symfony Framework or elsewhere where this controller is called by the Symfony kernel
- as long as there is the tiniest risk that Symfony < 3.3 could be installed by composer
- ie Symfony 2.8 is supported until close to the end of 2018 it will survive up to mid 2019 and more in distributions like Debian
- https://symfony.com/roadmap
$ composer req symfony-util/controller-using-templating-http-foundation-http-kernel
otherwise just
$ composer req symfony-util/controller-using-templating-http-foundation
Symfony configuration (kernel with MicroKernelTrait from symfony/framework)
symfony/routing
function configureRoutes(RouteCollectionBuilder $routes) { // ... $routes->add('/', SymfonyUtil\Controller\EngineAsArgumentController::class, 'index'); // ... }
symfony/dependency-injection
protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) { // ... $c->autowire(SymfonyUtil\Controller\EngineAsArgumentController::class) ->setAutoconfigured(true) ->addTag('controller.service_arguments') ->setPublic(false); // ...
Icon: https://material.io/icons/#ic_wallpaper
TODO
PHP 7
string arguments
- string arguments can officially be type-hinted from php 7.0
- http://php.net/manual/en/functions.arguments.php
Why code in scripts directory in 5.3 and 5.4 branches is not included in ^7?
Versions
PHP
5.5 TemplatingController::class in unit tests
5.6 __invoke(...$arguments) in VariadicController.php
7.0 (master)
- declare(strict_types=1);
- function f(): float
- function s(string $s)