- PHP 7.4 or above
- Composer required
- CodeIgniter 4.4.8
Clone project to your project root folder
composer create-project simpletine/codeigniter4-hmvc ci4_hmvc --stability=dev
Or
git clone https://github.com/Simpletine/CodeIgniter4-HMVC.git ci4_hmvc
Then
cd ci4_hmvc
Copy some require file to root folder (Upgrading to v4.4.8)
composer update
cp vendor/codeigniter4/framework/public/index.php public/index.php
cp vendor/codeigniter4/framework/spark spark
Copy env
file
cp env .env
Run the app, using different port, add options --port=9000
php spark serve
php spark make:module [module]
Create a blog module
php spark make:module blogs
App
├── Config
│ └── Routes.php (Added group called blogs)
├── Modules
│ └── Blogs
│ ├── Controllers
│ └── Blogs.php
│ ├── Models
│ └── BlogsModel.php
│ └── Views
│ └── index.php
└── ...
After generate Blogs
Module, add a route group for the module at App\Config\Routes.php
$routes->group(
'blogs', ['namespace' => '\Modules\Blogs\Controllers'], function ($routes) {
$routes->get('/', 'Blogs::index');
}
);
At App/Config/Autoload.php
, you can configure your custom namespace:
public $psr4 = [
// Sample
"$module" => APPPATH . "$module",
// Base on Example above
"Blogs" => APPPATH . "Modules/Blogs", // Example
// ...
];