Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Wrong named file / class may cause problems with loading?
  • Hi there, I'm still trying to implement some third party toolkits into Fuel but I have question.
    I have some files named like that:
    PREFIX_NameSomething.php with class inside it named PREFIX_NameSomething And I'm getting several errors depends on what method of including that class it use.
    Autoload:
    Fuel\Core\Fuel_Exception [ Error ]: Always load class does not exist. require_once():
    ErrorException [ Error ]: Class 'PREFIX_NameSomething' not found Might it be caused by wrong naming? I loaded several classes but that particulal class is abstract - some problems with abstract classes? :)
    Place where second error appers looks that: class PREFIX_Name extends PREFIX_NameSomething
    {
    ...
  • The error is caused when the autoloader can't find the class, will have nothing to do with it being abstract as the process doesn't care about instanciating it. Filepaths in fuel are fully lowercased and each underscore is translated into a directory separator. Thus this:
    PREFIX_NameSomething
    is expected at:
    app/classes/prefix/namesomething.php
  • So I have to change name of every class :/
    But what about require_once()? It's pure PHP so it should work fine whatever file / class name is.
  • Multi-file third party libs often come with their own autoloader or are best included using include/require. We put those into a "vendor" dir when we do this ourselves (check out core/vendor for example). Those are libs that are outside the normal autoloading and made by a third party.
  • Thanks, that really helped me.
    Only error that I occasionally get is:
    Warning: require(/opt/lampp/fuel/core/classes/Fuel\Core\Fuel) [function.require]: failed to open stream: No such file or directory in /opt/lampp/fuel/core/bootstrap.php on line 41
    Fatal error: require() [function.require]: Failed opening required '/opt/lampp/fuel/core/classes/Fuel\Core\Fuel' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/fuel/core/bootstrap.php on line 41

    This error seams to appear when I try to echo some values (just for testing). Strange thing is when I remove code including echo something; I still need to refresh page around 10 times to get it work (cache of something?).
    However, I successfully included third party library and it seems to work :D

Howdy, Stranger!

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

In this Discussion