Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter4 Modular Structure Application Starter
#1

(This post was last modified: 02-28-2022, 04:58 AM by XMadMax.)

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.
Reply
#2

(This post was last modified: 10-06-2020, 12:21 PM by nc03061981.)

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

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply
#3

(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/gener..._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 !!
Reply
#4

(This post was last modified: 10-07-2020, 01:27 AM by nc03061981.)

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

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply
#5

(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
Reply
#6

Yes
Thanks

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply
#7

(This post was last modified: 02-28-2022, 04:59 AM by XMadMax.)

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
Reply
#8

(This post was last modified: 02-28-2022, 06:28 AM by XMadMax.)

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.
Reply
#9

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;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

(This post was last modified: 03-01-2022, 01:38 AM by XMadMax.)

(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'
];
Reply




Theme © iAndrew 2016 - Forum software by © MyBB