Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Autoloader bug with custom namespaces?
  • Hello, I think I found a bug in the Autoloader. I have a File /my/path/classes/controller/directory/name.php with this :
    namespace My\Custom\Namespace;
    
    class Controller_Directory_Name extends \Controller {
        // ...
    }
    

    And somewhere else this:
    Autoloader::add_namespace('My\Custom\Namespace', '/my/path/classes/'); // With traling slash
    
    // And try this
    class_exists('My\Custom\Namespace\Controller_Directory_Name');
    

    Look here:
    https://github.com/fuel/core/blob/fcf88526205234a3b5d5d6553c7c3395c7fc83b3/classes/autoloader.php#L263 The controller file is searched within the path /my/path/classes//controller/directory/name.php (note the double slash here). $path = /my/path/classes/
    strtolower(substr($namespace, strlen($ns) + 1) is empty (no sub-namespace), so the path conains 2 / I think the handling of sub-namespaces is breaking the lookup in the defined namespace. [edit] For whatever reasons,
    is_file ('/path/with//double/slash')
    
    resolves the correct path, so it works. But I'm not sure this is a "feature".
  • Please report this as an issue on http://github.com/fuel/core/issues.

Howdy, Stranger!

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

In this Discussion