Welcome Guest, Not a member yet? Register   Sign In
Modules code example for codeigniter 4
#1

(This post was last modified: 06-30-2020, 04:38 AM by cvlancvlan.)

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";
    }
    

Reply




Theme © iAndrew 2016 - Forum software by © MyBB