CodeIgniter Forums
Access controller located in “folder_name/controller_name” in code-igniter 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Access controller located in “folder_name/controller_name” in code-igniter 4 (/thread-72684.html)



Access controller located in “folder_name/controller_name” in code-igniter 4 - tebogosebake - 01-24-2019

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?



RE: Access controller located in “folder_name/controller_name” in code-igniter 4 - kilishan - 01-24-2019

Your namespace must match the folder structure. This post should help clear it up, I think.