Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Is it possible to have modules inside packages?
  • I have an CMS package in which all basic CMS stuff is coded. But things get really big and i would like to separate some of the basic CMS controllers, models and views into modules. This might sound weird but i want to keep the application for what it is: extending the CMS i build. This way i only have to create a new 'app'. The modules i create in the app are for 'that' specific client only. The modules i create in the CMS package i use over and over again. My directory structure is like this (lib = just packages)
    /app/{all client code build on the cms}
    /lib/system/{fuel core}
    /lib/orm/{orm code}
    /lib/cms/{my cms code build on fuel + other packages}
    /public/{assets and index.php}
    

    So is it possible to have modules inside a package?
  • Official answer: No, you can't have modules in a package. Unofficial answer: FuelPHP supports multiple module folders, so nobody's stopping you from adding a modules folder to your package, and in the package bootstrap add the folder to the config module paths.
  • Harro Verton wrote on Tuesday 11th of September 2012:
    Official answer: No, you can't have modules in a package. Unofficial answer: FuelPHP supports multiple module folders, so nobody's stopping you from adding a modules folder to your package, and in the package bootstrap add the folder to the config module paths.

    So when i add a config.php in my CMS package and fill this in:
    <?php return array(
     'module_paths' => array(
         PKGPATH.'CMS'.DS.'modules'.DS,  // path to cms modules
     ),
     'always_load' => array(
      'modules' => array(
       'news',
      ),
     ),
    );
    

    Should this work? You talk about adding to bootstrap but i don't know what i have to do there. It seems that the packagename/config/config.php file is not being included automaticly. Am i forced to set the module_path inside
    app/config/config.php
    
    file? Thanks
  • Yes, that would work, but obviously creates a dependency between app and your package, which sort of makes it pointless to put them in a package in the first place. If this dependency exists simply create app/cms and put them there. If you want them in a package so they are portable, don't add it to app/config/config.php, but do this in the package bootstrap:
    $paths = \Config::get( 'module_paths', array() );
    $paths[] = __DIR__.DS.'classes'.DS.'modules'.DS;
    \Config::set('module_paths', $paths);
    
  • Ok, Thanks!

Howdy, Stranger!

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

In this Discussion