Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simpletine/codeigniter-4-hmvc
Implementing HMVC with CodeIgniter 4: In this approach, we group the Model-View-Controller components into packages called Modules, each acting as a self-contained unit of the application.
https://github.com/simpletine/codeigniter-4-hmvc
codeigniter4 hmvc-architecture php simpletine
Last synced: about 1 month ago
JSON representation
Implementing HMVC with CodeIgniter 4: In this approach, we group the Model-View-Controller components into packages called Modules, each acting as a self-contained unit of the application.
- Host: GitHub
- URL: https://github.com/simpletine/codeigniter-4-hmvc
- Owner: Simpletine
- License: mit
- Created: 2022-06-13T23:08:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-11T04:05:12.000Z (4 months ago)
- Last Synced: 2024-10-14T00:20:35.503Z (about 1 month ago)
- Topics: codeigniter4, hmvc-architecture, php, simpletine
- Language: PHP
- Homepage: https://github.com/Simpletine/CodeIgniter4-HMVC
- Size: 1.38 MB
- Stars: 10
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Codeigniter 4 HMVC
[![Official Website](https://img.shields.io/badge/Official_Website-Visit-yellow)](https://simpletine.com)
[![YouTube Channel](https://img.shields.io/badge/YouTube_Channel-Subscribe-FF0000)](https://www.youtube.com/channel/UCRuDf31rPyyC2PUbsMG0vZw)
### Prerequisites
1. PHP 7.4 or above
2. Composer required
2. CodeIgniter 4.4.8### Installation Guide
Clone project to your project root folder
```bash
composer create-project simpletine/codeigniter4-hmvc ci4_hmvc --stability=dev
```
Or
```bash
git clone https://github.com/Simpletine/CodeIgniter4-HMVC.git ci4_hmvc
```
Then
```bash
cd ci4_hmvc
```Copy some require file to root folder (Upgrading to v4.4.8)
```bash
composer update
cp vendor/codeigniter4/framework/public/index.php public/index.php
cp vendor/codeigniter4/framework/spark spark
```Copy `env` file
```bash
cp env .env
```Run the app, using different port, add options `--port=9000`
```bash
php spark serve
```---
## Module Commands
```bash
php spark make:module [module]
```### Example
Create a blog module
```bash
php spark make:module blogs
```### Result Directory
App
├── Config
│ └── Routes.php (Added group called blogs)
├── Modules
│ └── Blogs
│ ├── Controllers
│ └── Blogs.php
│ ├── Models
│ └── BlogsModel.php
│ └── Views
│ └── index.php
└── ...### Route Group
After generate `Blogs` Module, add a route group for the module at `App\Config\Routes.php`
```php
$routes->group(
'blogs', ['namespace' => '\Modules\Blogs\Controllers'], function ($routes) {
$routes->get('/', 'Blogs::index');
}
);
```## PSR4
At `App/Config/Autoload.php`, you can configure your custom namespace:
```php
public $psr4 = [
// Sample
"$module" => APPPATH . "$module",// Base on Example above
"Blogs" => APPPATH . "Modules/Blogs", // Example
// ...
];
```