admin管理员组文章数量:1296330
I have different custom Module paths/ Namespaces in my CodeIgniter4 project, and I just recently upgraded to version 4.4.0. in this upgrade the route settings will move from Config/Routes.php to Config/Routing.php file.
Now while I load my modules/namespace routes; my module routes are not identified because the $defaultNamespace setup is now in a different file.
How can I handle this?
I have added the Routes path to the $routesFiles parameter in the Routing.php
public array $routeFiles = [
APPPATH . 'Config/Routes.php',
'BudgetingModule\Config/Routes.php',
'FeeModule\Config/Routes.php',
];
I have different custom Module paths/ Namespaces in my CodeIgniter4 project, and I just recently upgraded to version 4.4.0. in this upgrade the route settings will move from Config/Routes.php to Config/Routing.php file.
Now while I load my modules/namespace routes; my module routes are not identified because the $defaultNamespace setup is now in a different file.
How can I handle this?
I have added the Routes path to the $routesFiles parameter in the Routing.php
public array $routeFiles = [
APPPATH . 'Config/Routes.php',
'BudgetingModule\Config/Routes.php',
'FeeModule\Config/Routes.php',
];
Share
Improve this question
asked Feb 11 at 21:30
Olisa AgbaforOlisa Agbafor
333 bronze badges
2 Answers
Reset to default 0I suspect your Routing includes are wrong. You currently have:
'BudgetingModule\Config/Routes.php',
'FeeModule\Config/Routes.php',
But you will need to make this something more like this:
'/var/www/html/path_to/BudgetingModule/Config/Routes.php',
'/var/www/html/path_to/FeeModule/Config/Routes.php',
Note also you have forward slashes and backslashes in the same path which might confuse things. Alternatively if your modules are in the APPPATH
location you can replace the /var/www/html/path
bit.
First, there is no need including the Route files in the $routeFiles since the modules are autoloaded and the Routes auto discovered.
But in each of the custom module config path, I included the Services.php file and in the Routes.php files, I brought back the former routes settings with the appropriate namespace to each of these files
in BudgetingModule\Config\Routes.php file
namespace BudgetingModule\Config;
// Create a new instance of our RouteCollection class.
$routes = Services::routes();
$routes->setDefaultNamespace('BudgetingModule\Controllers');
$routes->setDefaultController('Index');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->setAutoRoute(false);
版权声明:本文标题:codeigniter - Loading Route.php and Routing.php settings in different Modules in CodeIgniter4 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741633763a2389518.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论