Auto routing with modules in Codeigniter 4

1 day ago 1
ARTICLE AD BOX

I ran into this before. Try changing your $moduleRoutes in app/Config/Routing.php to:

public $moduleRoutes = [ 'tracking' => 'Modules\Tracking', ]

Then make sure your controller method is getSite() (not site()).

Also check that $autoRoutesImproved = true in app/Config/Feature.php.

If it still doesn't work, add a quick test module to be sure your autoload & routing are correct:

Create Modules/Test/Controllers/Home.php with a getIndex() method.

Add 'test' => 'Modules\Test' to $moduleRoutes.

Visit yourdomain.com/test/home/index.

If the test works, the issue is specific to your tracking module.

Otherwise, just use manual routes for now to get the site running:

$routes->get('tracking/main/site','Modules\Tracking\Controllers\Main::getSite');

Hope that helps

laoyang's user avatar

New contributor

laoyang is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Read Entire Article