routes.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Routes configuration.
  4. *
  5. * In this file, you set up routes to your controllers and their actions.
  6. * Routes are very important mechanism that allows you to freely connect
  7. * different URLs to chosen controllers and their actions (functions).
  8. *
  9. * It's loaded within the context of `Application::routes()` method which
  10. * receives a `RouteBuilder` instance `$routes` as method argument.
  11. *
  12. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  13. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  14. *
  15. * Licensed under The MIT License
  16. * For full copyright and license information, please see the LICENSE.txt
  17. * Redistributions of files must retain the above copyright notice.
  18. *
  19. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  20. * @link https://cakephp.org CakePHP(tm) Project
  21. * @license https://opensource.org/licenses/mit-license.php MIT License
  22. */
  23. use Cake\Routing\Route\DashedRoute;
  24. use Cake\Routing\RouteBuilder;
  25. /*
  26. * This file is loaded in the context of the `Application` class.
  27. * So you can use `$this` to reference the application class instance
  28. * if required.
  29. */
  30. return function (RouteBuilder $routes): void {
  31. /*
  32. * The default class to use for all routes
  33. *
  34. * The following route classes are supplied with CakePHP and are appropriate
  35. * to set as the default:
  36. *
  37. * - Route
  38. * - InflectedRoute
  39. * - DashedRoute
  40. *
  41. * If no call is made to `Router::defaultRouteClass()`, the class used is
  42. * `Route` (`Cake\Routing\Route\Route`)
  43. *
  44. * Note that `Route` does not do any inflections on URLs which will result in
  45. * inconsistently cased URLs when used with `{plugin}`, `{controller}` and
  46. * `{action}` markers.
  47. */
  48. $routes->setRouteClass(DashedRoute::class);
  49. $routes->scope('/', function (RouteBuilder $builder): void {
  50. /*
  51. * Here, we are connecting '/' (base path) to a controller called 'Pages',
  52. * its action called 'display', and we pass a param to select the view file
  53. * to use (in this case, templates/Pages/home.php)...
  54. */
  55. //$builder->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);
  56. /*
  57. * ...and connect the rest of 'Pages' controller's URLs.
  58. */
  59. //$builder->connect('/pages/*', 'Pages::display');
  60. $builder->connect('/plaintext', ['controller' => 'bench', 'action' => 'plaintext']);
  61. $builder->connect('/json', ['controller' => 'bench', 'action' => 'json']);
  62. $builder->connect('/db', ['controller' => 'bench', 'action' => 'db']);
  63. $builder->connect('/queries', ['controller' => 'bench', 'action' => 'queries']);
  64. $builder->connect('/updates', ['controller' => 'bench', 'action' => 'updates']);
  65. $builder->connect('/fortunes', ['controller' => 'bench', 'action' => 'fortunes']);
  66. /*
  67. * Connect catchall routes for all controllers.
  68. *
  69. * The `fallbacks` method is a shortcut for
  70. *
  71. * ```
  72. * $builder->connect('/{controller}', ['action' => 'index']);
  73. * $builder->connect('/{controller}/{action}/*', []);
  74. * ```
  75. *
  76. * You can remove these routes once you've connected the
  77. * routes you want in your application.
  78. */
  79. $builder->fallbacks();
  80. });
  81. /*
  82. * If you need a different set of middleware or none at all,
  83. * open new scope and define routes there.
  84. *
  85. * ```
  86. * $routes->scope('/api', function (RouteBuilder $builder): void {
  87. * // No $builder->applyMiddleware() here.
  88. *
  89. * // Parse specified extensions from URLs
  90. * // $builder->setExtensions(['json', 'xml']);
  91. *
  92. * // Connect API actions here.
  93. * });
  94. * ```
  95. */
  96. };