25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

97 satır
3.4KB

  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. /*
  61. * Connect catchall routes for all controllers.
  62. *
  63. * The `fallbacks` method is a shortcut for
  64. *
  65. * ```
  66. * $builder->connect('/{controller}', ['action' => 'index']);
  67. * $builder->connect('/{controller}/{action}/*', []);
  68. * ```
  69. *
  70. * It is NOT recommended to use fallback routes after your initial prototyping phase!
  71. * See https://book.cakephp.org/5/en/development/routing.html#fallbacks-method for more information
  72. */
  73. $builder->fallbacks();
  74. });
  75. /*
  76. * If you need a different set of middleware or none at all,
  77. * open new scope and define routes there.
  78. *
  79. * ```
  80. * $routes->scope('/api', function (RouteBuilder $builder): void {
  81. * // No $builder->applyMiddleware() here.
  82. *
  83. * // Parse specified extensions from URLs
  84. * // $builder->setExtensions(['json', 'xml']);
  85. *
  86. * // Connect API actions here.
  87. * });
  88. * ```
  89. */
  90. };

Powered by TurnKey Linux.