Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Any way to remove requirement for lowercase paths?
  • We're in the process of 'modernizing' our app and want to have class file names with uppercase characters. E.g., 

    \app\classes\FooBar.php

    As noted here http://fuelphp.com/blogs/2011/04/classnames-autoloading-namespaces FuelPHP only supports lowercase paths. 

    Is there anything we can do to remove this requirement? I've attempted to setup the composer.json file with something as follows:

        "autoload": {
            "psr-4": {
                "": ["fuel/app/classes/"],
            }
        },

    Have also tried psr-0. Neither have worked. 
  • Fuel doesn't support PSR-4, and using the composer autoloader to load Fuel specific classes is a bad idea. So it's rather pointless converting your class filenames.
  • We're not trying to load Fuel specific classes via composer autoloader. We only want to load in our own custom classes via composer. The existing Fuel classes can continue to fallback on Fuel's autoloader. That isn't an issue. 
  • Unless I am mis-understanding the question....

    In your vendor package composer.json just add in:
    "autoload": {
    "psr-4": { "MyClass\\": "src/" }
    }
  • yes, that works if we want to push all of our code into a src directory. We were hoping that there would be a way to keep our classes in the fuel/app/classes directory and have the composer autoloader look there first. However, it doesn't appear to work. 

        "autoload": {
            "psr-4": {
                "": ["fuel/app/classes/"],
            }
        },

    The above does allow us to properly load:

    \fuel\app\class\Foo\MyBar.php

    via

    new Foo\MyBar

    However, if we attempt to load a class in:

    fuel\app\classes\some\otherclass.php

    via 

    new Some\Otherclass;

    It will throw an exception due to the `some` directory name not having an uppercase first letter. 

    In the end, there doesn't appear to be any way to combine the two autoloaders and make them work.
  • ./fuel/app/classes contain Fuel classes. That need exclusively be loaded by Fuel's own autoloader.

    Like mikepmtl says, no problem using PSR-0 or PSR-4 to load your own classes (the Fuel autoloader supports PSR-0 at the moment, no need to use the composer autoloader for that), just use either the traditional composer way and create a separate package that gets installed in the vendor directory, or use a custom directory in ./fuel other than classes.

Howdy, Stranger!

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

In this Discussion