Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Autoloader doesn't find sub-directory classes in module directories
  • I've created an abstract class which I've placed in app/modules/modules/classes/base/driver.php. The purpose of this class is to provide a base driver class for module information classes. Each module contains a module.php file in the module's root directory which should extend the base driver in order to force methods such as install() and uninstall() for example.

    The autoloader however can't seem to locate the base driver using the structure I have specified, no matter what namespace and underscore convention I try to use. It doesn't appear to look for classes inside of sub-directories located within the modules/module_name/classes directory (i.e. base in my situation).

    I've pasted some code to illustrate my structure and files which I hope will provide a clearer picture of what I'm trying to achieve: http://pastebin.com/ummVNqss

    What am I doing wrong? Is this even possible? What are the alternatives?

    Appreciate your time and help!
  • HarroHarro
    Accepted Answer
    That should work fine, I don't see why not.

    Note that if you want to use this in other modules (such as members), you need to make sure the module is loaded first, otherwise the autoloader doesn't know where the "Modules" namespace maps to.

    Best thing to do is to add the "modules" module to the always_load section of the config to make sure it's always available.
  • Hi Harro!

    Adding the "modules" module to the always_load's module array seemed to do the trick!

    Great stuff :D Thanks!
  • You're welcome, happy coding! ;-)

Howdy, Stranger!

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

In this Discussion