# CodeIgniter

**CodeIgniter** 是一个开源的 PHP 全栈 Web 框架，最初由 EllisLab 开发，以模型-视图-控制器（MVC）模式组织应用，设计上强调在小体积下实现高性能、强能力和灵活性<sup>[1](https://codeigniter.com/user_guide/concepts/mvc.html?highlight=model+save)</sup><sup> • </sup><sup>[2](https://codeigniter.com/user_guide/concepts/goals.html)</sup><sup> • </sup><sup>[3](https://github.com/codeigniter4/CodeIgniter4/blob/develop/admin/starter/README.md)</sup>。首个公开版本于 2006 年 2 月 28 日发布，该框架目前由 CodeIgniter 基金会维护<sup>[4](https://api.ziyonet.uz/uploads/books/57178/5ae2ac037f07e.pdf)</sup><sup> • </sup><sup>[5](https://codeigniter.com/user_guide/intro/credits.html)</sup>。

| 关键事实 | 详情 |
|---|---|
| 语言与模式 | 使用模型-视图-控制器模式的 PHP 全栈 Web 框架<sup>[3](https://github.com/codeigniter4/CodeIgniter4/blob/develop/admin/starter/README.md)</sup><sup> • </sup><sup>[1](https://codeigniter.com/user_guide/concepts/mvc.html?highlight=model+save)</sup> |
| 首次发布 | 2006 年 2 月 28 日<sup>[4](https://api.ziyonet.uz/uploads/books/57178/5ae2ac037f07e.pdf)</sup> |
| 当前版本 | CodeIgniter 4.7.5（2026 年 10 月 9 日发布），适用于 PHP 8.2+；CodeIgniter 3.1.13 是面向 PHP 5.6+ 的旧版，处于维护状态，主要提供安全更新<sup>[6](https://github.com/codeigniter4/CodeIgniter4/releases)</sup><sup> • </sup><sup>[7](https://codeigniter.com/user_guide/intro/requirements.html)</sup><sup> • </sup><sup>[8](https://codeigniter.com/download)</sup> |
| 运行要求 | PHP 8.2 或更高版本，需启用 intl 和 mbstring 扩展<sup>[7](https://codeigniter.com/user_guide/intro/requirements.html)</sup> |
| 许可证与安装量 | MIT 许可证；codeigniter4/framework 在 Packagist 上约有 470 万次安装<sup>[9](https://packagist.org/packages/codeigniter4/framework)</sup> |
| 部署规模 | 检测到 281,474 个使用 CodeIgniter 的活跃网站，另有 1,224,087 个网站历史上曾使用过它<sup>[10](https://trends.builtwith.com/framework/CodeIgniter)</sup> |
| 管理归属 | 由 EllisLab 开发，2014 年被不列颠哥伦比亚理工学院收购，自 2019 年起由 CodeIgniter 基金会管理<sup>[5](https://codeigniter.com/user_guide/intro/credits.html)</sup> |

## 架构

CodeIgniter 使用 MVC 模式将应用的数据、展示和流程分离。模型负责管理数据并执行业务规则，视图是几乎不含逻辑的简单文件，负责向用户显示信息，控制器则充当胶水代码，在视图与数据存储之间调度数据。控制器和模型不过是承担特定职责的类，而框架采取相当宽松的方式：在 CodeIgniter 3 中，模型并非必需<sup>[1](https://codeigniter.com/user_guide/concepts/mvc.html?highlight=model+save)</sup><sup> • </sup><sup>[11](https://codeigniter.com/userguide2/overview/mvc.html)</sup>。

其宣称的设计目标是动态实例化——组件仅在需要时加载、例程仅在请求时执行，而非全局执行；松耦合——尽量减少组件之间的相互依赖；以及组件单一性——让每个类的用途都明确而专一<sup>[2](https://codeigniter.com/user_guide/concepts/goals.html)</sup>。

在数据库操作方面，CodeIgniter 提供了查询构建器（Query Builder）类，让信息的检索、插入和更新只需极少的脚本，通过各数据库适配器生成与数据库无关的查询语法，并自动转义值以实现更安全的查询<sup>[12](https://www.codeigniter.com/userguide3/database/query_builder.html?highlight=group)</sup>。与 [Yii](https://www.edgepedia.org/zh/yii) 和 CakePHP 不同，CodeIgniter 不使用对象关系映射（ORM）方案；它采用查询构建器，一种更过程化的方式，没有将数据库记录转换为对象的开销<sup>[13](https://ph.pollub.pl/index.php/iapgos/article/download/8358/5401/41917)</sup>。

## 历史与管理

CodeIgniter 最初由 EllisLab 开发，许多原始类库、辅助函数和子系统借自 ExpressionEngine 的代码库。多年来，它由 EllisLab、ExpressionEngine 开发团队以及一个名为 Reactor Team 的社区团体开发和维护。2014 年，CodeIgniter 被不列颠哥伦比亚理工学院收购，并正式宣布为社区维护项目。2019 年，CodeIgniter 基金会成立，作为一个独立于任何其他实体的永久性管理团体<sup>[5](https://codeigniter.com/user_guide/intro/credits.html)</sup>。

版本历史分为两条线。CodeIgniter 3 是旧版，面向 PHP 5.6 及更高版本，处于维护状态，主要接收安全更新，当前版本为 3.1.13<sup>[8](https://codeigniter.com/download)</sup>。CodeIgniter 4 初版发布于 2020 年 2 月 24 日，是为现代 PHP 重写的版本：框架中除辅助函数和语言文件外全部命名空间化，应用文件夹更名为 app，自动加载器（Autoloader）以 PSR-4 风格定位类，并支持 Composer 自动加载<sup>[8](https://codeigniter.com/download)</sup><sup> • </sup><sup>[14](https://codeigniter.com/user_guide/installation/upgrade_4xx.html?highlight=s)</sup>。版本 4 与版本 3 不向后兼容<sup>[14](https://codeigniter.com/user_guide/installation/upgrade_4xx.html?highlight=s)</sup>。

## CodeIgniter 4 实践

CodeIgniter 4 项目通常通过 appstarter 骨架仓库用 Composer 安装，命令为 `composer create-project codeigniter4/appstarter`，当框架发布新版本时用 `composer update` 更新<sup>[3](https://github.com/codeigniter4/CodeIgniter4/blob/develop/admin/starter/README.md)</sup>。框架附带命令行工具 Spark：`php spark serve` 会在 8080 端口启动本地开发服务器，文档指出绝不可在生产服务器上使用<sup>[15](https://codeigniter4.github.io/userguide/installation/running.html)</sup>。

版本 4.7.5 要求 PHP 8.2 或更高版本并启用 intl 和 mbstring 扩展，每个 PHP 版本对应一个最低 CodeIgniter 版本；例如 PHP 8.5 需要 CodeIgniter 4.7.0 或更高版本<sup>[7](https://codeigniter.com/user_guide/intro/requirements.html)</sup>。版本 4.7.0 新增了使用 FrankenPHP 的实验性工作模式（Worker Mode），FrankenPHP 是一个应用服务器，可在同一 PHP 进程内处理多个请求以提升性能<sup>[15](https://codeigniter4.github.io/userguide/installation/running.html)</sup>。

框架包含 CSRF 防护，用户管理可通过官方 Shield 库获得<sup>[16](https://www.usenix.org/system/files/usenixsecurity23-squarcina.pdf)</sup>。项目在 GitHub 上发布安全公告；近期公告包括查询构建器在配合 where() 条件使用 deleteBatch() 时的严重 SQL 注入、严重的上传文件扩展名验证绕过，以及 IncomingRequest::isSecure() 中可被伪造的转发 HTTPS 头的中危问题，均已在 4.7.4 中修补<sup>[17](https://github.com/codeigniter4/CodeIgniter4/security/advisories)</sup>。

## 性能与采用情况

2026 年一项对 CodeIgniter、CakePHP 和 Yii 的对比研究发现，CodeIgniter 在请求处理和响应生成方面是最快的框架，作者将这一结果归因于其查询构建器方式没有 ORM 开销。在负载下，包括 8,000 个虚拟用户时，CodeIgniter 产生的错误也始终少于其他框架，尽管其内存使用并不总是最低。同一研究还报告，按拉取请求计算，CodeIgniter 是三者中开发速度最慢的（2025 年为 211 个，而 CakePHP 为 317 个），GitHub 星标约 5,600 个，且 [Google Trends](https://www.edgepedia.org/zh/google-trends) 数据显示 CodeIgniter 和 CakePHP 的搜索热度在下降，而 Yii 保持稳定<sup>[13](https://ph.pollub.pl/index.php/iapgos/article/download/8358/5401/41917)</sup>。

采用数据反映出一个安装基数庞大但在新开发中份额较小的框架。BuiltWith 记录到 281,474 个活跃网站使用 CodeIgniter，其中 114,736 个在美国，另有 1,224,087 个网站历史上曾使用过它<sup>[10](https://trends.builtwith.com/framework/CodeIgniter)</sup>。在 [JetBrains](https://www.edgepedia.org/zh/jetbrains) 的《2025 年 PHP 现状》调查中，Laravel 以 64% 的使用率领先，其次是 [WordPress](https://www.edgepedia.org/zh/wordpress)（25%）和 [Symfony](https://www.edgepedia.org/zh/symfony)（23%），CodeIgniter、Yii 和 CakePHP 则占据较小但稳定的份额<sup>[18](https://blog.jetbrains.com/phpstorm/2025/10/state-of-php-2025/)</sup>。2026 年的一项调查显示 CodeIgniter 每月在 Packagist 上约有 500,000 次安装，GitHub 星标超过 5,000 个，而 Laravel 每月约有 2,500 万次安装，并称 CodeIgniter 学习曲线较低，最适合中小型项目<sup>[19](https://www.phpeveryday.com/articles/laravel-vs-symfony-vs-other-php-frameworks-2026-survey/)</sup>。

CodeIgniter 对 PHP 发展史的影响可以从其竞争对手身上看到：2011 年 6 月，泰勒·奥特威尔（Taylor Otwell）发布了 Laravel 1 的首个测试版，意在解决 CodeIgniter 未能提供的用户认证等基础功能的缺失。<sup>[20](https://beei.org/index.php/EEI/article/download/2064/1400)</sup>

## References

1. [Models, Views, and Controllers, CodeIgniter 4.7.4 User Guide](https://codeigniter.com/user_guide/concepts/mvc.html?highlight=model+save)
2. [Design and Architectural Goals, CodeIgniter 4.7.4 User Guide](https://codeigniter.com/user_guide/concepts/goals.html)
3. [CodeIgniter 4 Application Starter README, codeigniter4/CodeIgniter4 on GitHub](https://github.com/codeigniter4/CodeIgniter4/blob/develop/admin/starter/README.md)
4. [Practical part, Ziyonet hosted text on CodeIgniter history](https://api.ziyonet.uz/uploads/books/57178/5ae2ac037f07e.pdf)
5. [Credits, CodeIgniter 4.7.4 User Guide](https://codeigniter.com/user_guide/intro/credits.html)
6. [Releases, codeigniter4/CodeIgniter4 on GitHub](https://github.com/codeigniter4/CodeIgniter4/releases)
7. [Server Requirements, CodeIgniter 4.7.5 User Guide](https://codeigniter.com/user_guide/intro/requirements.html)
8. [Welcome to CodeIgniter (download page)](https://codeigniter.com/download)
9. [codeigniter4/framework, Packagist.org](https://packagist.org/packages/codeigniter4/framework)
10. [CodeIgniter Usage Statistics, BuiltWith](https://trends.builtwith.com/framework/CodeIgniter)
11. [Model-View-Controller, CodeIgniter 2.2.6 User Guide](https://codeigniter.com/userguide2/overview/mvc.html)
12. [Query Builder Class, CodeIgniter 3.1.13 User Guide](https://www.codeigniter.com/userguide3/database/query_builder.html?highlight=group)
13. [Comparative analysis of web development frameworks in PHP: CodeIgniter, CakePHP and Yii, IAPGOŚ 1/2026](https://ph.pollub.pl/index.php/iapgos/article/download/8358/5401/41917)
14. [Upgrading from 3.x to 4.x, CodeIgniter 4.7.4 User Guide](https://codeigniter.com/user_guide/installation/upgrade_4xx.html?highlight=s)
15. [Running Your App, CodeIgniter 4.7.5 User Guide](https://codeigniter4.github.io/userguide/installation/running.html)
16. [Framework-based CSRF analysis, USENIX Security 2023](https://www.usenix.org/system/files/usenixsecurity23-squarcina.pdf)
17. [Security Advisories, codeigniter4/CodeIgniter4 on GitHub](https://github.com/codeigniter4/CodeIgniter4/security/advisories)
18. [The State of PHP 2025, JetBrains PhpStorm blog](https://blog.jetbrains.com/phpstorm/2025/10/state-of-php-2025/)
19. [Laravel vs Symfony vs Other PHP Frameworks: 2026 Survey, PHP Everyday](https://www.phpeveryday.com/articles/laravel-vs-symfony-vs-other-php-frameworks-2026-survey/)
20. [Security features comparison of CodeIgniter, Laravel, and Symfony, BEEI](https://beei.org/index.php/EEI/article/download/2064/1400)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Frameworks, libraries, and APIs › Web frameworks and libraries

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/codeigniter

English original: https://www.edgepedia.org/codeigniter
