What is the MVC pattern in CodeIgniter?
Why Interviewers Ask This
This is a classic screening question for CodeIgniter roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
CodeIgniter follows the MVC (Model-View-Controller) architectural pattern. The Model handles data access — it interacts with the database and contains data-related logic. The View contains the HTML presentation layer — what the user sees. The Controller is the glue — it receives HTTP requests, calls models for data, passes data to views, and returns responses. In CodeIgniter, the URL structure maps directly to controllers and methods: /blog/index calls the index() method of the Blog controller. The flow: Client → Router → Controller → Model → View → Controller → Response. This separation makes code organized, reusable, and testable, especially for large applications.
Common Mistake
Many candidates answer correctly but can't explain the 'why'. Always be prepared to justify your answer with a concrete example or use case from your CodeIgniter experience.