Skip to content

Instantly share code, notes, and snippets.

@dweingart
Last active December 23, 2015 00:39
Show Gist options
  • Save dweingart/6554643 to your computer and use it in GitHub Desktop.
Save dweingart/6554643 to your computer and use it in GitHub Desktop.
Slim Framework - Routes that call different methods based on query args only
<?php
// http://www.example.com/foo
$app->get('/foo',
// route middleware throws Pass exception based on query arg variables.
function() use ($app)
{
$getVars = $app->request->params();
if (isset($getVars['hello']) && ('world' == $getVars['hello']))
{
throw new \Slim\Exception\Pass;
}
}, function ()
{
echo '<p><b>Foo Was Called</b></p>';
});
// http://www.example.com/foo?hello=world
$app->get('/foo',
function ()
{
echo '<p><b>Hello, World</b></p>';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment