Created
August 23, 2015 00:32
-
-
Save cspray/143765b968e21082bcb4 to your computer and use it in GitHub Desktop.
Labrador HTTP - Possible Route Handlers
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 | |
use Symfony\Component\HttpFoundation\Response; | |
// Have a simple enough Response? No fuss, no muss just pass a Response object | |
$engine->get('/', new Response('Hello World')); | |
// Need something a tad more advanced? How about an anonymous functions! | |
$engine->get('/', function() { | |
return new Response('Hello World'); | |
}); | |
// Maybe an object is more up your alley? | |
class MyController { | |
public function action() { | |
return new Response('Hello World'); | |
} | |
} | |
// The ControllerActionResolver will instantiate this controller using the | |
// Auryn\Injector for the given request. | |
$engine->get('/', MyController::class . '#action'); | |
// If you need your own fancy handler that can't fit into one of the above patterns | |
// you can implement your own Cspray\Labrador\Http\Router\HandlerResolver. It can | |
// then be added to the ResolverChain or can completely take place of the HandlerResolver | |
// used for routing. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment