Need Help with Modules |
Hello! I'm trying to add independent modules to my application. I am following the official Guide.
https://codeigniter4.github.io/userguide...dules.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.
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. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(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}
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; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
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).
|
Welcome Guest, Not a member yet? Register Sign In |