![]() |
Need Help with Modules - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Need Help with Modules (/showthread.php?tid=75616) |
Need Help with Modules - Programaciones Web - 02-26-2020 Hello! I'm trying to add independent modules to my application. I am following the official Guide. https://codeigniter4.github.io/userguide/general/modules.html But seems like I missed something... Cause I am getting a 404 error when I try to access to the Default Home Controller of my Blog Module. Basically the first thing I did is create a new folder in the Project Root app/ public/ system/ writable/ modules/ modules/Blog/ modules/Blog/config/ modules/Blog/Controllers/ modules/Blog/Models/... ... ... Then I create a new namespace for this modules folder in app/Config/Autoload.php PHP Code: $psr4 = [ After that I add that to the Active Explorers (I am not sure what I have to add here... The name of the Namespace? Folder?) app/Config/Modules.php PHP Code: public $activeExplorers = [ Next Step is add the Route to the app/Config/Routes.php PHP Code: $routes->group('blog', ['namespace' => 'Modules\Blog\Controllers'], function($routes) But I got a 404 when I call this route... (baseURL)/blog modules/Blog/Controllers/Home.php - I dont know if have to change the namespace inside Blog Controller... But I tried too... and still the same. PHP Code: <?php namespace App\Controllers; Thanks. RE: Need Help with Modules - InsiteFX - 02-26-2020 Modules is your route module namespace you need to add another one for your blog. PHP Code: 'Modules' => ROOTPATH . 'Modules' // MODULES Add that to your Autoload. RE: Need Help with Modules - Programaciones Web - 02-26-2020 (02-26-2020, 04:05 PM)InsiteFX Wrote: Modules is your route module namespace you need to add another one for your blog. Thanks for your answer but It didn't work. Still showing 404. Controller or its method is not found: {0}::{1} RE: Need Help with Modules - InsiteFX - 02-27-2020 Did you create a Config folder in your Blog Module with a Routes file? Modules\Blog .. Config .... Routes.php My Admin module is at: Insitefx/Admin Insitefx/Admin .. Config .... Routes.php This is how I have my first routes setup using a routes group. PHP Code: <?php The bottom route uses the route->to in html. Just think that your module is another application everything goes in it controllers etc; RE: Need Help with Modules - MGatner - 03-01-2020 I think it should work with the namespaces configured as InsiteFX has noted. You will need your module controllers to use the same namespace though - so above where you noted have App\Controllers use the commented version (and BaseController will need to be fully namespaced unless you have your own in your module). |