Search code examples
phprepositorycomposer-phppsr-0

How to autoload a repository in composer which does not follow PSR-0 or PSR-4?


So, I'm trying to use jcleblanc/reddit-php-sdk, but it follows no standards whatsoever and does not have a repository available, so I've had to manually define it myself in my composer.json file:

"repositories" : [{
    "type": "package",
    "package": {
        "name": "jcleblanc/reddit-php-sdk",
        "version": "dev-master",
        "source": {
            "url": "https://github.com/jcleblanc/reddit-php-sdk",
            "type": "git",
            "reference": "origin/master"
        },
        "autoload": {
            "classmap": ["reddit-php-sdk/", "/", "reddit.php", "config.php"]
        }
    }
}],

Directory structure in vendor/ here:

enter image description here

However, when I then run composer dump-autoload, the classes in this project are not autoloaded, and don't appear in any of the autoload_*.php composer files. This means I of course get a "Class 'reddit' not found" error whenever I try and use it.

Solutions?


Solution

  • Ended up forking the project myself, but it turns out the original project is broken anyway.