CodeIgniter Forums

Full Version: Access controller located in “folder_name/controller_name” in code-igniter 4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can i access my controller located in “folder_name/controller_name” in codeigniter 4?


Quote:My Master controller located in "admin" folder. View image 
[Image: VRtLl.png]

Code:
namespace App\Controllers\admin;
use CodeIgniter\Controller;
class Master extends Controller
{
function __construct(){
helper('url');
}
public function index()
{
$data["content"]="view_home";
echo view('template/template', $data);
}
}

Quote:In my Routes.php i added this

Code:
$routes->get('admin/master','Master::index',['namespace','App\Controllers\admin']);

Quote:when i access the page in the browser i get this error

404 - File Not Found Controller or its method is not found: {0}::{1}
What am i missing?
Your namespace must match the folder structure. This post should help clear it up, I think.