Skip to content

Instantly share code, notes, and snippets.

View derrabus's full-sized avatar
🥃
Digging in old code again.

Alexander M. Turek derrabus

🥃
Digging in old code again.
View GitHub Profile
<?php
namespace Acme\MyApp\Controller;
use Psr\Container\ContainerInterface;
class MyController
{
private $container;
@derrabus
derrabus / MyController.php
Created February 5, 2018 16:48
Container-aware Silex Controller with PSR-11
<?php
namespace Acme\MyApp\Controller;
use Psr\Container\ContainerInterface;
class MyController
{
public function myAction(ContainerInterface $container): string
{
@derrabus
derrabus / MyController.php
Created February 5, 2018 15:28
DI-enabled Silex Controller
<?php
namespace Acme\MyApp\Controller;
use Twig\Environment;
class MyController
{
private $twig;
@derrabus
derrabus / MyController.php
Last active February 5, 2018 15:12
Silex Controller with Application Dependency
<?php
namespace Acme\MyApp\Controller;
use Silex\Application;
class MyController
{
private $app;
@derrabus
derrabus / MyController.php
Last active February 5, 2018 15:16
Application-aware Silex Controller
<?php
namespace Acme\MyApp\Controller;
use Silex\Application;
class MyController
{
public function myAction(Application $app): string
{
@derrabus
derrabus / dump_routes.php
Created December 20, 2017 16:30
Extract Symfony routing configuration from a Silex application
#!/usr/bin/env php
<?php
use Silex\Application;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCompiler;
use Symfony\Component\Yaml\Yaml;
require_once __DIR__ . '/vendor/autoload.php';