• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modules code example for codeigniter 4

#1
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


Messages In This Thread
Modules code example for codeigniter 4 - by cvlancvlan - 06-30-2020, 02:28 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.