1

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',
    ];
   

2 Answers 2

0

I 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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Anthony for your response, The BudgetingModule and the other are defined modules autoloaded in the Autoload.php file. Again, even with the same delimiters, they still dont respond I have also tried specifying the full path to the module routes, yet I keep getting pageNotFound when I visit any of the routes defined in those custom modules
Have you tried \Namespace\Path\Module\Class::method in your routes file? Another possibility - as the route destination
0

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.