2017 © Pedro Peláez
 

library controller-using-templating-http-foundation

Controller which renders a template and returns a response (HttpFoundation)

image

symfony-util/controller-using-templating-http-foundation

Controller which renders a template and returns a response (HttpFoundation)

  • Sunday, March 11, 2018
  • by Nardberjean
  • Repository
  • 1 Watchers
  • 0 Stars
  • 555 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

controller-using-templating-http-foundation

Controller which renders a template and returns a response (HttpFoundation), (*1)

PHPPackages Rank Monthly Downloads PHPPackages Referenced By Tested PHP Versions Dependency Status Build Status Code Coverage Scrutinizer SensioLabsInsight , (*2)

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, (*3)

$ 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, (*4)

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)

The Versions