Skip to content

Instantly share code, notes, and snippets.

@felixmc
Last active December 29, 2015 19:19
Show Gist options
  • Save felixmc/7716541 to your computer and use it in GitHub Desktop.
Save felixmc/7716541 to your computer and use it in GitHub Desktop.
<?php
/*
* Load controllers for setting up manual controller routes to allow for dynamic custom page routes
* */
$controllers = array();
foreach (scandir( APPPATH . "controllers" ) as $file) {
$fileParts = explode(".", $file);
if ($fileParts[1] === "php")
array_push($controllers, $fileParts[0]);
}
$route['default_controller'] = "home";
$route['404_override'] = '';
// add controllers to routes
foreach ($controllers as $controller) {
$route[$controller . '/(:any)'] = $controller . '/$1';
$route[$controller] = $controller ;
}
$route[':any'] = "staticpage";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment