Welcome Guest, Not a member yet? Register   Sign In
Problem in routing
#1

(This post was last modified: 12-16-2019, 06:01 PM by Dedov_Evgeniy.)

Hello.
Created a folder "Modules" with modules in the root ...
In file autoload.php
PHP Code:
$psr4 = [
            
'Config'      => APPPATH  'Config',
            
APP_NAMESPACE => APPPATH,                // For custom namespace
            
'App'         => APPPATH,                // To ensure filters, etc still found,
            
'Modules'     => ROOTPATH 'Modules',
        ]; 


structure in the module folder:
Content
   - Config
   - Controllers
   - Models
   - Libraries
   ...
   ...
create controller: ContentAdminController
PHP Code:
namespace Modules\Content\Controllers;

// use CodeIgniter\Controller;

class ContentAdminController extends \CodeIgniter\Controller
{
    public function index()
    {
    echo 
123;
    }


add route:
PHP Code:
$routes->add('admin''ContentAdminController::index', ['namespace' => 'Modules\Content\Controllers']); 
url is work!
http://name_site.ru/admin

add route:
PHP Code:
$routes->add('admin/(:any)''$1::index', ['namespace' => 'Modules\Content\Controllers']); 
url is not work!
http://name_site.ru/admin/ContentAdminController

Help, why the class does not work dynamically? thanks
Reply


Messages In This Thread
Problem in routing - by Dedov_Evgeniy - 12-16-2019, 05:59 PM
RE: Problem in routing - by Dedov_Evgeniy - 12-23-2019, 10:12 AM
RE: Problem in routing - by Digital_Wolf - 12-23-2019, 02:44 PM
RE: Problem in routing - by Dedov_Evgeniy - 12-23-2019, 04:56 PM
RE: Problem in routing - by Digital_Wolf - 12-24-2019, 03:55 AM
RE: Problem in routing - by InsiteFX - 12-24-2019, 04:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB