Welcome Guest, Not a member yet? Register   Sign In
Autorouting is not working for Controller created inside sub-directory of Controllers
#1
Sad 

I have created a controller in a sub-directory under app/Controllers/Admin but unable to access it via autorouting methods like localhost/admin . The code for that is given below:
 
PHP Code:
<?php namespace App\Controllers\Admin;

use 
App\Controllers\BaseController;

class 
Admin extends BaseController
{
public function 
index()
{
return 
view('welcome_message');
}

//-------------------------------------------------------------------- 
}

I think I have set up everything correctly from the docs. I have installed the ci4 using composer and adjusted the .env for development, added virtual host too. However, only custom route is working and also when I specify the whole directory for the controller like localhost/admin/admin.

Code:
/**
* --------------------------------------------------------------------
* Router Setup
* --------------------------------------------------------------------
*/
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);

Please Help if I made any silly mistakes or is this a bug?

The error I am getting is : 404, the controller cannot be found
Reply


Messages In This Thread
Autorouting is not working for Controller created inside sub-directory of Controllers - by wizardone - 07-24-2020, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB