1- # Codeigniter 4 HMVC
2-
31[ ![ 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 )
42
5- ### Prerequisites
3+ # Codeigniter 4 HMVC
4+ This repository features a modular HMVC (Hierarchical Model-View-Controller) architecture for CodeIgniter 4, integrated with the official authentication system, CodeIgniter 4 Shield. It also includes a comprehensive Admin Dashboard built with AdminLTE, providing a robust foundation for scalable and secure web applications.
5+
6+ ## Prerequisites
671 . PHP 7.4 or above
782 . Composer required
892 . CodeIgniter 4.4.8
910
10- ### Installation Guide
11+ # Installation Guide
1112
1213Clone project to your project root folder
1314``` bash
14- composer create-project simpletine/codeigniter4-hmvc ci4_hmvc --stability=dev
15+ git clone https://github.com/Simpletine/CodeIgniter4-HMVC.git ci4_hmvc
1516```
17+
1618Or
19+
1720``` bash
18- git clone https://github.com/Simpletine/CodeIgniter4-HMVC.git ci4_hmvc
21+ composer create-project simpletine/codeigniter4-hmvc ci4_hmvc --stability=dev
22+ ```
23+
24+ Copy ` env ` file
25+ ``` bash
26+ cp env .env
1927```
20- Then
28+
29+ Run the app, using different port, add options ` --port=9000 `
2130``` bash
22- cd ci4_hmvc
23- ```
31+ php spark serve
32+ ```
33+
34+ ## Database Configuration
35+ Create database & sessions migration
2436
25- Copy some require file to root folder (Upgrading to v4.4.8)
37+ ``` bash
38+ php spark db:create ci4_shield
39+ ```
40+
41+ ``` bash
42+ php spark make:migration --session
43+ php spark shield:setup
44+ ```
45+
46+
47+ ## Default Auth
48+
49+ ``` bash
50+ email: super@admin.com
51+ password: password
52+ ```
53+
54+ ## Create User
55+ Use command line to create a new user
56+ ``` bash
57+ php spark shield:user create
58+ ```
59+
60+ ## Notice
61+ If you are using old versions, after composer update, you need to update the ` index.php ` and ` spark ` file to root folder (Upgrading to v4.4.8)
2662``` bash
2763composer update
2864cp vendor/codeigniter4/framework/public/index.php public/index.php
2965cp vendor/codeigniter4/framework/spark spark
3066```
3167
32- Copy ` env ` file
68+ # Module Commands
69+ Commands available and funcationality
70+
71+ ## General
72+ Create a new module named ` Blogs `
3373``` bash
34- cp env .env
74+ php spark module:create Blogs
3575```
3676
37- Run the app, using different port, add options ` --port=9000 `
77+ Clone a existing module of ` Blogs ` and renamed to ` Items `
3878``` bash
39- php spark serve
79+ php spark module:copy Blogs Items
4080```
4181
82+ Create a controller to module ` Blogs ` named ` Categories.php `
83+ ``` bash
84+ php spark module:controller Blogs Categories
85+ ```
4286
43- ---
44- ## Module Commands
87+ Create a model to module ` Blogs ` named ` Categories.php `
4588``` bash
46- php spark make: module [module]
89+ php spark module:model Blogs Categories
4790```
4891
49- ### Example
50- Create a blog module
92+ ## Admin
93+ Additional options for the commands
94+
95+ Create a new controller and view to ` Admin ` module with ` AdminLTE `
5196``` bash
52- php spark make: module blogs
97+ php spark module:controller Admin Users --admin
5398```
5499
55- ### Result Directory
100+ ## Modules Directory
56101 App
57102 ├── Modules
58103 │ └── Blogs
@@ -67,23 +112,33 @@ php spark make:module blogs
67112 └── ...
68113
69114### Route Group
70- After generate ` Blogs ` Module, the routes group for the module at ` Modules\Config\Routes.php `
115+ Add new subroutes to ` blogs ` named ` new ` with method name
116+
117+ ``` php
118+ $routes->get('new', 'Blogs::new');
119+ ```
120+
121+ Sample of routes group after new subroutes
71122``` php
72123$routes->group(
73124 'blogs', ['namespace' => '\Modules\Blogs\Controllers'], function ($routes) {
74125 $routes->get('/', 'Blogs::index');
126+ $routes->get('new', 'Blogs::new');
75127 }
76128);
77129```
78130
79- ## PSR4
131+ # PHPCS
132+
133+ Default instance of containing all rules applicable for the CodeIgniter organization
134+ ``` bash
135+ composer run fix
136+ ```
137+
138+ # PSR4
80139At ` App/Config/Autoload.php ` , you can configure your custom namespace:
81140``` php
82141public $psr4 = [
83- // Sample
84- "$module" => APPPATH . "$module",
85-
86- // Base on Example above
87142 "Blogs" => APPPATH . "Modules/Blogs", // Example
88143 // ...
89144];
0 commit comments