CodeIgniter Forums
CI4 Question (Module Calling Module) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CI4 Question (Module Calling Module) (/showthread.php?tid=79544)



CI4 Question (Module Calling Module) - [email protected] - 06-30-2021

Hi Everyone,

Can you tell me how to call a module within a module.


RE: CI4 Question (Module Calling Module) - paliz - 07-01-2021

The best exmple is math auth and learn how to implement ed in ci4

https://github.com/lonnieezell/myth-auth


RE: CI4 Question (Module Calling Module) - ikesela - 07-01-2021

(06-30-2021, 10:14 PM)[email protected] Wrote: Hi Everyone,

Can you tell me how to call a module within a module.

what are you trying to do?


RE: CI4 Question (Module Calling Module) - [email protected] - 07-01-2021

(07-01-2021, 03:04 AM)ikesela Wrote:
(06-30-2021, 10:14 PM)[email protected] Wrote: Hi Everyone,

Can you tell me how to call a module within a module.

what are you trying to do?

Hi, I am using HMVC in Codeigniter 4 functionality and I want to call a module in the another module.

Like, IN CI3 we use below line,
Modules::run('dashboard/index', $data); So, How we can use this in CI4


RE: CI4 Question (Module Calling Module) - InsiteFX - 07-01-2021

Create a route to it using the modules namespace see the CodeIgniter User Guide URI Routing.

Ig you need link it in html then look in the url helper for route_to()


RE: CI4 Question (Module Calling Module) - [email protected] - 07-01-2021

(07-01-2021, 09:18 PM)InsiteFX Wrote: Create a route to it using the modules namespace see the CodeIgniter User Guide URI Routing.

Ig you need link it in html then look in the url helper for route_to()


 Modules::run() This function is not working in CI4. So, can you please tell me what is the solution for that?


RE: CI4 Question (Module Calling Module) - InsiteFX - 07-04-2021

PHP Code:
$module = new \Namespace\ModuleName(); 

Add your own module static method called run(). then you can call 
PHP Code:
$module::run(); 

You will need to setup your run method for any parameters to pass.


RE: CI4 Question (Module Calling Module) - [email protected] - 07-05-2021

(07-04-2021, 02:42 AM)InsiteFX Wrote:
PHP Code:
$module = new \Namespace\ModuleName(); 

Add your own module static method called run(). then you can call 
PHP Code:
$module::run(); 

You will need to setup your run method for any parameters to pass.

Thank you