CodeIgniter Basic Tutorial
Performance & Utilities
CodeIgniter Advanced
In CodeIgniter, a Controller is a PHP class that acts as the middleman between the user (browser) and your application logic.
It receives requests from the browser, processes them (using models if needed), and then loads the appropriate view.
application/controllers/
(CodeIgniter 3)app/Controllers/
(CodeIgniter 4)Returns a rendered HTML view with optional data passed to the view.
return view('page_view', $data);
Redirects the user to a different URL or route within the application.
return redirect()->to('/dashboard');
Sends a JSON-formatted response, typically used for APIs or AJAX requests.
public function getData() { return $this->response->setJSON(['a', 'b', 'c']); }