Codeigniter controllers subfolders


Codeigniter controllers subfolders: You can organize your controller file in subfolders.


Codeigniter controllers subfolders Example

First create a folder name as “admin” inside controllers ie . “application/controllers/admin”.

Suppose we are developing the admin module in our project and we want to keep separate it from the front end files.
Now we will add each controllers in admin folder which will belong to admin module.

Codeigniter controllers subfolders

Codeigniter controllers subfolders

We have created a controller named as “login” inside the folder “application/controllers/admin/”

<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Login extends CI_Controller { 	 	public function index() 	{ 		$this->load->view('login_view');
	}
}


Now for Accessing the login view you have to access the url “http://localhost/admin/login” which will load the login page of the admin module.


Advertisements

Add Comment

đź“– Read More