Skip to content

Instantly share code, notes, and snippets.

@jakefolio
Created February 16, 2012 21:38
Show Gist options
  • Save jakefolio/1848068 to your computer and use it in GitHub Desktop.
Save jakefolio/1848068 to your computer and use it in GitHub Desktop.
Only load the routes you want based off of URI params
<?php
// Stupid dirty example of how to load only the routes you want.
$app->hook('slim.before.router', function() use ($app) {
$uri = $app->request()->getResourceUri();
$params = explode('/', substr($uri, 1, strlen($uri)));
if (file_exists(APP_ROOT . '/app/routes/' . $params[0] . '.php'))
include APP_ROOT . '/app/routes/' . $params[0] . '.php';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment