Created
October 25, 2017 20:21
-
-
Save peterlafferty/0191df195091bb7d8a7e6e278968088d to your computer and use it in GitHub Desktop.
web/index.php showing how to not passing di container in to controllers
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
<?php | |
require_once __DIR__ . '/../vendor/autoload.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use pl\tddcontroller\TddController; | |
$app = new Silex\Application(); | |
$app['controller.tdd'] = function () use ($app) { | |
return new TddController( | |
$app['charset'] | |
); | |
}; | |
$app->get('/cities/{id}', function (int $id) use ($app) { | |
return $app['controller.tdd']->get($id); | |
})->assert("id", "\d+"); | |
$app->get('/cities/', function (Request $request) use ($app) { | |
return $app['controller.tdd']->getAll( | |
$request->query->all() | |
); | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment