Routes.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Config;
  3. // Create a new instance of our RouteCollection class.
  4. $routes = Services::routes();
  5. // Load the system's routing file first, so that the app and ENVIRONMENT
  6. // can override as needed.
  7. if (is_file(SYSTEMPATH . 'Config/Routes.php')) {
  8. require SYSTEMPATH . 'Config/Routes.php';
  9. }
  10. /*
  11. * --------------------------------------------------------------------
  12. * Router Setup
  13. * --------------------------------------------------------------------
  14. */
  15. $routes->setDefaultNamespace('App\Controllers');
  16. $routes->setDefaultController('Home');
  17. $routes->setDefaultMethod('index');
  18. $routes->setTranslateURIDashes(false);
  19. $routes->set404Override();
  20. // The Auto Routing (Legacy) is very dangerous. It is easy to create vulnerable apps
  21. // where controller filters or CSRF protection are bypassed.
  22. // If you don't want to define all routes, please use the Auto Routing (Improved).
  23. // Set `$autoRoutesImproved` to true in `app/Config/Feature.php` and set the following to true.
  24. // $routes->setAutoRoute(false);
  25. /*
  26. * --------------------------------------------------------------------
  27. * Route Definitions
  28. * --------------------------------------------------------------------
  29. */
  30. // We get a performance increase by specifying the default
  31. // route since we don't have to scan directories.
  32. //$routes->get('/', 'Home::index');
  33. $routes->get('plaintext', 'Bench::plaintext');
  34. $routes->get('json', 'Bench::json');
  35. $routes->get('fortunes', 'Bench::fortunes'); // /(:num)
  36. $routes->get('db', 'Bench::db');
  37. $routes->get('queries/(:alphanum)', 'Bench::queries/$1');
  38. $routes->get('queries/', 'Bench::queries/1');
  39. $routes->get('update/(:alphanum)', 'Bench::update/$1');
  40. $routes->get('update/', 'Bench::update/1');
  41. /*
  42. * --------------------------------------------------------------------
  43. * Additional Routing
  44. * --------------------------------------------------------------------
  45. *
  46. * There will often be times that you need additional routing and you
  47. * need it to be able to override any defaults in this file. Environment
  48. * based routes is one such time. require() additional route files here
  49. * to make that happen.
  50. *
  51. * You will have access to the $routes object within that file without
  52. * needing to reload it.
  53. */
  54. if (is_file(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
  55. require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
  56. }