I am building an app in codeigniter and my application folder hierarchy goes like this:
|-controller
|-admin
|-dashboard
I want to add dashboard to the namespace admin
, so I did this:
defined('BASEPATH') OR exit('No direct script access allowed');
namespace admin;
class Dashboard extends MY_Controller {
//constructor and some methods
}
The problem is that whenever i try to access the dashboard class from uri localhost/myapp/admin/dashboard
, I get error on the browser like this:
Server error
500
However if I comment out the line namespace admin;
, it runs without any errors.
Why is the namespace creating such internal server error?
How to prevent such error while using namespaces for controller class in codeigniter?