Created
March 22, 2015 18:49
-
-
Save ckmaresca/cc56d01bfc43b432e740 to your computer and use it in GitHub Desktop.
Call Slim route with parameters from within Slim
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
$app->post('/routePart/:param/anotherRoutePart', function ($param) { | |
// Code to call comes here | |
})->name('yourChoiceOfRouteName'); | |
// Get route | |
$ourRoute = $app->router->getNamedRoute('yourChoiceOfRouteName'); | |
// Set url params | |
$ourRoute->setParams(['param'=> $param]); | |
// Set post params | |
$_POST = array('postParamA'=>'A', 'postParamB'=>'B'); | |
// Run query | |
$result = $ourRoute->dispatch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment