Created
March 3, 2015 19:00
-
-
Save hannesvdvreken/8b83f00ebf0c69cb4555 to your computer and use it in GitHub Desktop.
league/route with methodargumentstrategy and registered callables
This file contains hidden or 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 | |
use League\Container\Container; | |
use League\Route\RouteCollection; | |
use League\Route\Strategy\MethodArgumentStrategy; | |
use Symfony\Component\HttpFoundation\Request; | |
require 'vendor/autoload.php'; | |
$container = new Container(); | |
$router = new RouteCollection($container); | |
$router->setStrategy(new MethodArgumentStrategy()); | |
$router->post('/user/{username}', 'create_controller'); | |
$container->add(Request::class, function () { | |
return Request::create('/user/philipobenito', 'POST'); | |
}); | |
$container->invokable('create_controller', function (Request $request, $username) { | |
var_dump('invokable', $request->getMethod(), $username); exit; | |
})->withArgument(Request::class); | |
$router->getDispatcher()->dispatch('POST', '/user/philipobenito'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment