Routing.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * This file is part of CodeIgniter 4 framework.
  4. *
  5. * (c) CodeIgniter Foundation <admin@codeigniter.com>
  6. *
  7. * For the full copyright and license information, please view
  8. * the LICENSE file that was distributed with this source code.
  9. */
  10. namespace Config;
  11. use CodeIgniter\Config\Routing as BaseRouting;
  12. /**
  13. * Routing configuration
  14. */
  15. class Routing extends BaseRouting
  16. {
  17. /**
  18. * For Defined Routes.
  19. * An array of files that contain route definitions.
  20. * Route files are read in order, with the first match
  21. * found taking precedence.
  22. *
  23. * Default: APPPATH . 'Config/Routes.php'
  24. *
  25. * @var list<string>
  26. */
  27. public array $routeFiles = [
  28. APPPATH . 'Config/Routes.php',
  29. ];
  30. /**
  31. * For Defined Routes and Auto Routing.
  32. * The default namespace to use for Controllers when no other
  33. * namespace has been specified.
  34. *
  35. * Default: 'App\Controllers'
  36. */
  37. public string $defaultNamespace = 'App\Controllers';
  38. /**
  39. * For Auto Routing.
  40. * The default controller to use when no other controller has been
  41. * specified.
  42. *
  43. * Default: 'Home'
  44. */
  45. public string $defaultController = 'Home';
  46. /**
  47. * For Defined Routes and Auto Routing.
  48. * The default method to call on the controller when no other
  49. * method has been set in the route.
  50. *
  51. * Default: 'index'
  52. */
  53. public string $defaultMethod = 'index';
  54. /**
  55. * For Auto Routing.
  56. * Whether to translate dashes in URIs for controller/method to underscores.
  57. * Primarily useful when using the auto-routing.
  58. *
  59. * Default: false
  60. */
  61. public bool $translateURIDashes = false;
  62. /**
  63. * Sets the class/method that should be called if routing doesn't
  64. * find a match. It can be the controller/method name like: Users::index
  65. *
  66. * This setting is passed to the Router class and handled there.
  67. *
  68. * If you want to use a closure, you will have to set it in the
  69. * routes file by calling:
  70. *
  71. * $routes->set404Override(function() {
  72. * // Do something here
  73. * });
  74. *
  75. * Example:
  76. * public $override404 = 'App\Errors::show404';
  77. */
  78. public ?string $override404 = null;
  79. /**
  80. * If TRUE, the system will attempt to match the URI against
  81. * Controllers by matching each segment against folders/files
  82. * in APPPATH/Controllers, when a match wasn't found against
  83. * defined routes.
  84. *
  85. * If FALSE, will stop searching and do NO automatic routing.
  86. */
  87. public bool $autoRoute = false;
  88. /**
  89. * For Defined Routes.
  90. * If TRUE, will enable the use of the 'prioritize' option
  91. * when defining routes.
  92. *
  93. * Default: false
  94. */
  95. public bool $prioritize = false;
  96. /**
  97. * For Defined Routes.
  98. * If TRUE, matched multiple URI segments will be passed as one parameter.
  99. *
  100. * Default: false
  101. */
  102. public bool $multipleSegmentsOneParam = false;
  103. /**
  104. * For Auto Routing (Improved).
  105. * Map of URI segments and namespaces.
  106. *
  107. * The key is the first URI segment. The value is the controller namespace.
  108. * E.g.,
  109. * [
  110. * 'blog' => 'Acme\Blog\Controllers',
  111. * ]
  112. *
  113. * @var array<string, string>
  114. */
  115. public array $moduleRoutes = [];
  116. /**
  117. * For Auto Routing (Improved).
  118. * Whether to translate dashes in URIs for controller/method to CamelCase.
  119. * E.g., blog-controller -> BlogController
  120. *
  121. * If you enable this, $translateURIDashes is ignored.
  122. *
  123. * Default: false
  124. */
  125. public bool $translateUriToCamelCase = true;
  126. }