kenjis / ci4-app-template
CodeIgniter4 应用程序模板
v44.5.0
2024-02-03 07:42 UTC
Requires
- php: ^7.4 || ^8.0
- codeigniter4/codeigniter4: ^4.2
- codeigniter4/translations: dev-develop
- liaison/revision: ^1.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- codeigniter4/devkit: ^1.0
- fakerphp/faker: ^1.9
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^9.1
- tatter/patches: ^2.1
Suggests
- ext-fileinfo: Improves mime type detection for files
README
此模板更改了 CI4 的默认配置,使其更加安全。
此存储库包含
- CodeIgniter 4.4.5
- CodeIgniter 4 系统消息翻译 dev-develop
- CodeIgniter DevKit 1.2.0
- PHPUnit 9.6.16
- Tatter\Patches 2.1.0
- Liaison Revision 1.1.0
- bear/qatools 1.10.0
要求
- PHP 7.4 或更高版本
如何安装
Composer
$ composer create-project kenjis/ci4-app-template your-project
Git
$ git clone https://github.com/kenjis/ci4-app-template.git your-project $ cd your-project/ $ composer install $ git checkout -b main
如何更新
更新 Composer 包
$ composer update
更新你的 CodeIgniter4 项目文件
$ php spark revision:update
如何使用
服务
- 所有服务都必须手动添加到
app/Config/Services.php
,即使第三方 CI4 包有自己的服务。
CSRF
- 你必须手动设置表单中的 CSRF 令牌字段。见 https://codeigniter4.github.io/CodeIgniter4/libraries/security.html#html-forms
CSP
- 当你需要时必须设置 CSP。见 https://codeigniter4.github.io/CodeIgniter4/outgoing/response.html#content-security-policy
- 对于内联内容,你需要使用
csp_script_nonce()
和csp_style_nonce()
。见 https://codeigniter4.github.io/CodeIgniter4/outgoing/response.html#inline-content
与 CI4 默认配置的更改
服务
- 服务自动发现被禁用。见 app/Config/Modules.php。
Config\Services
扩展了CodeIgniter\Config\Services
。见 app/Config/Services.php。
配置
- 移除了 BaseURL 的
index.php
。 - 自动路由(改进)已启用。
Config\CURLRequest::$shareOptions
被禁用。(自 v4.4.0 版本起,默认已设置。)- MySQLi 的
numberNative
已启用。 - 使用基于会话的 CSRF 保护。
- CSRF保护
$tokenRandomize
已启用。 - CSP已启用。
- CSP
$autoNonce
已禁用。 - 使用严格的验证规则。(自v4.3.0起,默认设置。)
过滤器
- CSRF过滤器已启用。
- InvalidChars过滤器已启用。
- SecureHeaders过滤器已启用。
功能
Config\Feature::$multipleFilters
已启用。
其他
- 使用
develop
版本的CI4。 app/Config/Paths.php。
可用命令
composer test // Run PHPUnit
composer cs-fix // Fix the coding style
composer cs // Check the coding style
composer sa // Run static analysis
composer run-script --list // List all commands
与CodeIgniter 4.x相关的项目
库
- CodeIgniter 3到4升级助手
- 类似于CodeIgniter 3的验证码
- PHPUnit助手
- CodeIgniter4属性路由
- CodeIgniter简单安全的Twig
- CodeIgniter4 Viewi演示