Hubert

PSR-7

As you have learned in the routes section thier target functions get the $request and $response variables returned

"mvc" => array(
   "route" => "/[:controller]/[:action]",
   "method" => "GET|POST",
   "target" => function($request, $response, $args){
        echo "Controller: {$args['controller']}, Action: {$args['action']}";
    }
),

These are PSR-7 standardized objects. Hubert uses the PSR-7 Implementation from Zend.This is a short example on how to use it.

"test" => array(
    "route" => "/test",
    "method" => "GET|POST",
    "target" => function($request, $response, $args){
        $get_params = $request->getQueryParams();
        $html = "Get Params: ".print_r($get_params, true);
        $response->getBody()->write($html);
        return $response;
    }
),

For instance if you call the url /test?name=hubert the route returns "Get Params: Array("name" => "hubert")". Hubert expects a PSR-7 object from every route by default. For compatibility reasons routes can also return strings or even nothing. The server request is globally available using hubert()->request.