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