Home » Php » php – Composer not auto-loading package

php – Composer not auto-loading package

Posted by: admin July 12, 2020 Leave a comment


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:


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

How to&Answers:

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"]


Just requiring a package, does not force composer to autoload the package.

Have a look into autoloading with composer, but something like these should get you started:

autoload: {
    "classmap": ["vendor/koraktor/steam-condenso/lib"]