Search code examples
phplaravelcomposer-phpsteam-condenser

Composer not auto-loading package


I'm currently working on Laravel 4. I have added the following to my composer.json, and ran the update:

    "require": {
        ...
        "koraktor/steam-condenser": "*"

The package: https://packagist.org/packages/koraktor/steam-condenser

The issue I'm having is that if I call one of the classes it uses, for example:

$steamUser = new SteamId('000000000000000000');
echo "Welcome, " . $steamUser->getNickname() . "<br />";

I get the error Class 'SteamId' not found

If I manually require the file needed, then it works perfectly:

require_once('/home/path-to-laravel/laravel/vendor/koraktor/steam-condenser/lib/steam-condenser.php');

I've ran composer dump-autoload and still doesn't work. Does anyone know why this is? It's really frustrating me :(


Solution

  • Steam Condenser is not (yet) compliant to PSR-0, so you have to use a different autoloading approach (see http://getcomposer.org/doc/04-schema.md#autoload).

    Using the files method should be best suited here:

    {
        "autoload": {
            "files": ["vendor/koraktor/steam-condenser/lib/steam-condenser.php"]
        }
    }