简体   繁体   中英

How can i access my controller located in “folder_name/controller_name” in codeigniter 4?

My Master controller located in "admin" folder. View image here

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);
}
}

In my Routes.php i added this

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

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?

My silly mistake when setting up the route. I've put a "," instead of "=>". See the correct route below.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM