CodeIgniter Forums

Full Version: Modules code example for codeigniter 4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If i don't use routes for this app/Modules/Product/Controllers/ProductController.php how can i acces this controller from url ?
If i use this route then url for this controller app/Modules/Product/Controllers/ProductController.php is sitename[.]ext/productx

Hou can i route all controller class from this path App/Modules/Controllers/ to this url sitename[.]ext/module/controller/method/params...
This is possible in codeigniter 4 ?

app/Config/Routes.php

PHP Code:
$routes->group('', ['namespace' => 'Modules\Product\Controllers'], function($routes){
    
$routes->get('productx''ProductController::index');
}); 

app/Config/Autoload.php

PHP Code:
$psr4 = [
    
'App'                 => APPPATH,
    
APP_NAMESPACE         => APPPATH,
    
'Config'              => APPPATH 'Config',
    
'Modules\Product'     => APPPATH 'Modules/Product',
]; 

app/Modules/Product/Controllers/ProductController.php

PHP Code:
<?php namespace Modules\Product\Controllers;
use 
CodeIgniter\Controller;

class 
ProductController extends Controller {
    
    public function 
index() {
        echo 
"productx index";
    }