okfsoft/ci4-hmvc
Composer 安装命令:
composer require okfsoft/ci4-hmvc
包简介
CodeIgniter v4 HMVC
README 文档
README
CODEIGNITER 4 HMVC STARTER
≡ About ci4-hmvc
This is a project archive that we use to make it easier for us to build web applications based on the CodeIgniter4 framework. Hopefully it can be useful.
CodeIgniter is a php based framework and works on the MVC (Model-View-Controller) pattern. Can also use Hierarchical Model View Controller (HMVC). HMVC stands for Hierarchical Model View Controller. This is the latest version of the HMVC pattern used for web applications. Provide solutions to help you address application scalability such as easy module updates.
≡ Table of contents
- Requirements
- Feature List
- Installation Preparation
- How to use
- Credit
≡ Requirements
≡ Feature list
This is a list of some features or functionality that you can use.
- HMVC Architecture
- BaldeOne Templating Engine
≡ Preparation & Installation
To get ready to install packages, you have to install codeigniter 4 appstarter with composer, or you can follow the user guide to install using composer.
Now the next step is to add the rule in composer.json in your project root, and add the following rule to make it work after the installation is complete, or you can skip this preparation and add it manually in step number 03.
+ "autoload": { + "psr-4": { + "Modules\\Application\\": "modules/application", + "Modules\\Resources\\": "modules/resources" + } + }
01. Install library via composer:
composer require okfsoft/ci4-hmvc
02. Distribute HMVC
Now you can distribute the library can be done via spark:
php spark hmvc:publish
This will copy and distribute the sample hmvc structure folder in your project root parallel to the codeigniter4 app folder.
03. Modify Autoload.php
( Ignore rule number 03 if you have added autoload in composer.json ).
Next you need to modify psr-4 settings on Autoload.php file on app/Config/Autoload.php and add below rules
public $collectors = [
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
+ 'Modules\Application' => ROOTPATH . 'modules/application',
+ 'Modules\Resources' => ROOTPATH . 'modules/resources',
];
];
≡ Use of HMVC
You can try running php spark serve to run codeigniter development and visiting http://localhost:8080/starter it will load hmvc modules/application/Starter which will show if there are no problems during installation.
When you http://localhost:8080/starter/blade will load hmvc starter using BladeOne Template Engine
01. Router Settings
You can make Routes.php settings for each new module created in the modules/application/{Module_name}/Config.php directory, using this code sample:
<?php $routes->group('home', ['namespace' => $hmvcNamespace], function ($routes) { $routes->get('/', 'Home::index'); $routes->match(['get', 'post'], "(:any)", "home::$1"); });
You can use BladeOne Rendering which comes in the package. or use with the help of Class Helper
≡ Helpers
| Parameter | Information |
|---|---|
return renderView('home', $data); |
HMVC Display Rendering using Default |
return renderBlade('home', $data); |
HMVC Display Rendering using BladeOne |
More info useful link
Credit
okfsoft/ci4-hmvc 适用场景与选型建议
okfsoft/ci4-hmvc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 107 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ci4 hmvc」 「codeigniter4 hmvc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 okfsoft/ci4-hmvc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 okfsoft/ci4-hmvc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 okfsoft/ci4-hmvc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
JSON Web Token for codeigniter4 authentication.
ORM Database mapping for Codeigniter 4
An Example of CodeIgniter 4 Page module
An Example of CodeIgniter 4 Menu module
An Example of CodeIgniter 4 Blog module
An Example of CodeIgniter 4 Page diaporama
统计信息
- 总下载量: 107
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-14