What is the difference between CodeIgniter 3 and CodeIgniter 4?

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 4 is a complete rewrite of CI3 with modern PHP practices. Key differences: CI4 requires PHP 7.4+ (CI3 supported PHP 5.6+). CI4 uses namespaces and PSR-4 autoloading (CI3 used a custom autoloader without namespaces). CI4 has a proper HTTP layer with Request/Response objects (CI3 had a single Input class). CI4 has built-in migrations and seeders (CI3 had a simpler migrations library). CI4 has a Model class with validation and callbacks (CI3 models were bare). CI4 uses Filters instead of CI3's Hooks. CI4 has first-class CLI support via Spark. CI4 is Composer-first (CI3 was typically downloaded as a zip). CI4 supports dependency injection via Services. The application code structure changed significantly — CI3 apps cannot be directly migrated to CI4.

Pro Tip

Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex CodeIgniter answers easy to follow.