CodeIgniter Forums
CodeIgniter4 Modular Structure Application Starter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34)
+--- Thread: CodeIgniter4 Modular Structure Application Starter (/showthread.php?tid=77696)



CodeIgniter4 Modular Structure Application Starter - XMadMax - 10-06-2020

This is an autoinstaller app (composer), to understand how to create a modular app.

Includes a simple register/login/logout.

All modules and all dependencies are in the same directory, mantaining the base CI4 structure:

Code:
app/Modules/Users/Config
app/Modules/Users/Controllers
app/Modules/Users/Databases/Migrations
app/Modules/Users/Databases/Seeds
app/Modules/Users/Filters
app/Modules/Users/Language
app/Modules/Users/Libraries
app/Modules/Users/Models
app/Modules/Users/Validation
app/Modules/Users/Views

To install & test, follow instructions on https://github.com/XXPerez/Codeigniter4Modular

Code:
composer create-project xxperez/codeigniter4modular

Take a view to the example controllers and libraries, it's very easy !!

Fell free to comment and contribute to it. Thanks.


RE: CodeIgniter4 Modular Structure Application Starter - nc03061981 - 10-06-2020

With CI4, I think this is not necessary.
Simple can sub folder or https://codeigniter.com/user_guide/general/managing_apps.html
...
CI3 + HMVC + ... + = CI4


RE: CodeIgniter4 Modular Structure Application Starter - XMadMax - 10-06-2020

(10-06-2020, 12:20 PM)nc03061981 Wrote: With CI4, I think this is not necessary.
Simple can sub folder or https://codeigniter.com/user_guide/general/managing_apps.html
...
CI3 + HMVC + ... + = CI4

Hi NC, for me, this is not the same, separate apps does not share anything.

I have found that I need share common libaries, helpers, languages, but also there are specific parts of a project that I like to be isolated, but with all components inside the same structure.

This is only an example of how can be done with subfolders as you say.

Also, I have old apps in CI3 that give me the possibility to migrated them to CI4 with few code changes.

The beter of CI4 is that you can choose the structure that better fits to your needs !!


RE: CodeIgniter4 Modular Structure Application Starter - nc03061981 - 10-07-2020

If you change the folder Modules = folder Packages, because Packages are better suited to CI4.

With CI4 you should dev 2 seperate Packages: package Users and package Dashboard are better suited to CI4. Users can composer them is better.

Or both in one Package


RE: CodeIgniter4 Modular Structure Application Starter - XMadMax - 10-07-2020

(10-07-2020, 01:13 AM)nc03061981 Wrote: If you change the folder Modules = folder Packages, because Packages are better suited to CI4.

With CI4 you should dev 2 seperate Packages: package Users and package Dashboard are better suited to CI4. Users can composer them is better.

Or both in one Package

Yes, of course it could be a package, but only if you want to give public access to the code.
For private development, I prefer Modules.

Thanks


RE: CodeIgniter4 Modular Structure Application Starter - nc03061981 - 10-07-2020

Yes
Thanks


RE: CodeIgniter4 Modular Structure Application Starter - XMadMax - 10-14-2020

Modular Updated:

Added ModuleCreate to allow creation of php module base files

In your ROOTPATH:
Code:
php spark module:create Modulename

This command, create this files:
  • App/Modules/[Modulename]/Config/Routes.php
  • App/Modules/[Modulename]/Controllers/[Modulename].php
  • App/Modules/[Modulename]/Libraries/[Modulename]Lib.php
  • App/Modules/[Modulename]/Models/[Modulename]Model.php
  • App/Modules/[Modulename]/Views/index.php

Also, can create this empty directories, for future use:
  • App/Modules/[Modulename]/Database/Migrations
  • App/Modules/[Modulename]/Database/Seeds
  • App/Modules/[Modulename]/Filters
  • App/Modules/[Modulename]/Language
  • App/Modules/[Modulename]/Validation

Options:
Code:
php spark module:create Modulename -f ModulesDirectory
Create Modulename under ROOTPATH/[ModulesDirectory], not under default APPPATH/Modules

Code:
php spark module:create Modulename -c FCLMVO
Create only this options: con[F]ig, [C]ontroller, [L]ibrary, [M]odel, [V]iew, [O]ther dirs


To install & test, follow instructions on https://github.com/XXPerez/Codeigniter4Modular

Or:
Code:
composer create-project xxperez/codeigniter4modular



RE: CodeIgniter4 Modular Structure Application Starter - XMadMax - 02-28-2022

Codeigniter4Modular

Solved some problems on install
Refactory for user login/register example

Project :  https://github.com/XXPerez/Codeigniter4Modular

Install:
Code:
composer create-project xxperez/codeigniter4modular

Or follow composer instructions to install.


RE: CodeIgniter4 Modular Structure Application Starter - InsiteFX - 03-01-2022

If you want private modules then you should place them in the root along with the app and system folders

app
system
Modules
-- Blog
-- Users
-- etc;


RE: CodeIgniter4 Modular Structure Application Starter - XMadMax - 03-01-2022

(03-01-2022, 01:24 AM)InsiteFX Wrote: If you want private modules then you should place them in the root along with the app and system folders

app
system
Modules
-- Blog
-- Users
-- etc;

Thanks for the tip, the modules directory can be placed anywhere, only changing the Autoload.php file:

Code:
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config'      => APPPATH . 'Config',
                APP_NAMESPACE.'/Controllers' => APPPATH.'Controllers',
                'Home' => APPPATH . '../Modules/Home' ,
                'Users' => APPPATH . '../Modules/Users' ,
                'Utils' => APPPATH . '../Modules/Utils'
];