I'm implementing the Klein router in php and I have a little problem... I would like to call a special function from my controller, giving it (or not) $request variable like this :
$klein->respond('GET', '/[i:id]?', HomeController::view($request));
But I have the error : Uncaught InvalidArgumentException: Expected a callable. Got an uncallable NULL So I changed my code to :
$klein->respond('GET', '/[i:id]?', new HomeController::view($request));
and now the error is this one : syntax error, unexpected 'view' (T_STRING), expecting variable (T_VARIABLE) or '$' Finally I found a solution writting my code like this :
$klein->respond('GET', '/[i:id]?', function($request){ HomeController::view($request); });
This one is working but I feel I'm missing something... I would like to factorize this, is there any solution? Thanks you