Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuel::get_paths() and modules
  • With the default APPPATH/config/config.php, Fuel::get_paths() returns...
    array (
        0 => '/home/me/git/fuel/fuel/app/',
        1 => '/home/me/git/fuel/fuel/core/',
    )
    
    ...which is expected. Enabling ORM in the 'Always Load' section,
    'always_load' => array(
        'packages' => array(
            'orm',
    ...
    
    produces this result...
    array (
        0 => '/home/me/git/fuel/fuel/app/',
        1 => '/home/me/git/fuel/fuel/packages/orm/',
        2 => '/home/me/git/fuel/fuel/core/',
    )
    
    ...which is also expected. So far, so good. Now, enabling a specific module in the config file...
    'module_paths' => array(
        APPPATH.'modules'.DS
    ),
    ...
    'always_load' => array(
        'modules' => array('module01'),
    ...
    
    produces this result...
    array (
        0 => '/home/me/git/fuel/fuel/app/',
        1 => '/home/me/git/fuel/fuel/packages/orm/',
        2 => '/home/me/git/fuel/fuel/core/',
    )
    
    ...which I thought would have included the module's path as indice #0. Am I not getting it (again)?
  • Modules are not added to global search paths, because it would ruin module separation. Files are found in Fuel via the Fuel::find_file() method, using a relative name/path and a time. If you add a module to the global search path, all of a sudden every view load is going through your module directory as well. Which almost certainly will break your application at one point, unless you've been very creative with file names. For example, suppose every module has a admin controller, including views, to provide management for that module. You modules produce widgets for your page, so you have multiple modules loaded. Now your code does
    View::factory('admin/index');
    
    Can you tell me which view is loaded? No. It will depend on if modules are loaded, which are loaded, and in which sequence. Nightmare guaranteed!
  • Thanks for taking the time to explain in such a clear manner. It would indeed be a mess having several modules in a system with all of them being in the global search paths. I know that you and Jelmer have better things to do than answer noob questions such as mine and I want you guys know I am appreciative.

Howdy, Stranger!

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

In this Discussion