Skip to content

Instantly share code, notes, and snippets.

@ckmaresca
Created March 22, 2015 18:49
Show Gist options
  • Save ckmaresca/cc56d01bfc43b432e740 to your computer and use it in GitHub Desktop.
Save ckmaresca/cc56d01bfc43b432e740 to your computer and use it in GitHub Desktop.
Call Slim route with parameters from within Slim
$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