• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Access controller located in “folder_name/controller_name” in code-igniter 4

#1
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?
Reply

#2
Your namespace must match the folder structure. This post should help clear it up, I think.
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.