CodeIgniter is a lightweight PHP framework that follows the Model-View-Controller (MVC) pattern. It gives you a small core, helpers and libraries for routing, database access, forms, validation and sessions, so you can build websites and APIs without wiring everything yourself. This tutorial covers what CodeIgniter is, which version to choose in 2026, how a request flows, and a first controller and view.
Use CodeIgniter 4 for new projects. Version 3 is an old line that does not support modern PHP, so only maintain it where you must.
spark CLI, which makes common tasks faster.For large applications with many packages, teams often compare it with Laravel or Symfony, which have bigger ecosystems.
| Feature | CodeIgniter 3 | CodeIgniter 4 |
|---|---|---|
| PHP version | Legacy PHP 5.x and 7.x era | PHP 8.1 or newer for current releases |
| Namespaces and autoloading | No | Yes, with Composer |
| Routing | Config array | Route collection with groups and filters |
| CLI | Limited | spark command |
| Status | Not suited to new work | Actively maintained |
Check the official documentation for the exact minimum PHP version of the release you install.
The recommended method is Composer.
Open http://localhost:8080 and you will see the welcome page. Configuration lives in .env, which you copy from the env file and edit for the base URL, environment and database.
public/index.php, the single entry point.app/Config/Routes.php.Keep the document root pointed at the public folder, never at the project root, so application code and .env are not reachable from the web.
Add a route in app/Config/Routes.php:
Create the controller app/Controllers/Hello.php:
Create the view app/Views/hello.php:
Visiting /hello/Asha now shows "Hello, Asha!". The esc() function escapes output and protects against cross-site scripting, so use it for every user-supplied value.
Once this works, learn the models and the query builder, then validation, migrations and the spark make: generators. The official user guide for your version is the best reference, at https://codeigniter.com/user_guide/.
Yes, for small and medium projects and for teams that value simplicity. For large systems, compare it with Laravel and Symfony first.
Yes. Point the document root at public, or upload the files so that only public is web accessible.
CodeIgniter 4 has ResourceController and ResponseTrait, which make JSON APIs straightforward.
MySQL and MariaDB, PostgreSQL, SQLite, SQL Server and Oracle drivers are available through the database library.
CodeIgniter is a compact PHP MVC framework that is quick to learn. Start new projects on CodeIgniter 4, install with Composer, keep public as the web root, escape output with esc(), and use controllers, models and views to keep code organised.