Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Module inside Module
  • Hi,

    I was thinking about creating a module inside a module.

    I am creating an admin module, and there are some smaller modules I would like to create. It HAS to be a module because it needs routing, but it is a different module. How can it be done?
  • It should be possible insert your module B inside another module A simply following these steps:
    1. Copy you module B folder in module A folder
    2. edit your config and specify module B path in "module_paths"
    3. edit your config file and load the module normally in modules
    Now you can use it like other modules, the system doesn't know that it is in a subfolder.


  • Do you mean 'config' is the 'global', app config, or the config in the module? Can I make this config in modules/modulea/config/config.php?

    Can I specify it under the module A namespace?

    So I can reach it by \ModuleA\ModuleB\Class. Is it possible. If not, how can I make it not a module inside the module, but an other namespace. Eg.: \ModuleA\Namespace\Class?
  • Good question, I've to try it myself before answer.
    I'll try to have a look this evening.
  • Thanks. Let me know. I am trying too, but did not succeded.
  • HarroHarro
    Accepted Answer
    Technically, you can define an entire list of paths that may contain modules. FuelPHP doesn't care where that is, so it's not a problem to do:

    'module_paths' => array(
        APPPATH.'modules',
        APPPATH.'modules'.DS.'mainmodule',
    ),

    The downside is that, since that 'mainmodule' directory contains folders like 'classes', 'config', 'views', etc, these will now be seen as module names. Which means URL's starting with these will go very wrong, so you need to capture those in your routing an route to your 404 handler to avoid that.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion