You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a question about your great router ...
I'm implementing it in my project and I had a question ... From my controller how can i Know which method was used? Post, Get, Patch or Delete?
Example :
In my routes.php file I have : $klein->respond(['GET', 'PATCH'], '/posts/create', ['PostsController', 'create']);
So how in my controller I can know if the function was called in GET or in PATCH? public static function create($req, $res, $serv, $app) { if (PATCH) { //save to bdd } else { $params = [ 'datas'=> [ 'pageTitle' => 'Créer un nouveau Post' ], ]; echo $app->twig->render('Posts/create.html', $params); } }
Thanks you
edit :
Sorry, I know that in pure php you can use $_SERVER['REQUEST_METHOD'] to know the method used, but maybe in your Klein router you provide it?
The text was updated successfully, but these errors were encountered:
Hi, I have a question about your great router ...
I'm implementing it in my project and I had a question ... From my controller how can i Know which method was used? Post, Get, Patch or Delete?
Example :
In my routes.php file I have :
$klein->respond(['GET', 'PATCH'], '/posts/create', ['PostsController', 'create']);
So how in my controller I can know if the function was called in GET or in PATCH?
public static function create($req, $res, $serv, $app)
{
if (PATCH) {
//save to bdd
} else {
$params = [
'datas'=> [
'pageTitle' => 'Créer un nouveau Post'
],
];
echo $app->twig->render('Posts/create.html', $params);
}
}
Thanks you
edit :
Sorry, I know that in pure php you can use
$_SERVER['REQUEST_METHOD']
to know the method used, but maybe in your Klein router you provide it?The text was updated successfully, but these errors were encountered: