Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Pixelairport's avatar

Composer Autoload for my own package

I spend 4 hours now and i cant fix it. I build an composer package which is loaded from github via composer require. It also loads the files, but the autoloader will not include the new path to src folder. I also did composer dump-autoload.

The package is loded into "vendor/pixelairport/platform-api2" and this is my composer.json in this package:

{
    "name": "pixelairport/platform-api2",
    "description": "Base for APIs with Platform applications.",
    "type": "library",
    "autoload": {
        "classmap": [
            "src/"
        ],
        "psr-4": {
            "Pixelairport\PlatformApi2\": "src/"
        }
    },
    "minimum-stability": "dev",
    "require": {}
}

Hope somebody can help. Thx.

0 likes
5 replies
primordial's avatar

Can you post a link to the actual package? Easier to spot the mistake.

primordial's avatar

Change

"Pixelairport\PlatformApi2\": "src/"

to

"Pixelairport\PlatformApi2\": "src"

And you don't need a classmap

Pixelairport's avatar

I tried it but it doesn't work. Also other packages have "src/". It seems my autoload files are not updated. Also with autoload-dump -o... could it be the problem is my main composer file, because I require the package from github like this:

{
            "type":"package",
            "package": {
                "name": "pixelairport/platform-api2",
                "version":"1.0",
                "source": {
                    "url": "https://github.com/pixelairport/platform-api2.git",
                    "type": "git",
                    "reference":"1.0"
                }
            }
        },
Pixelairport's avatar
Pixelairport
OP
Best Answer
Level 12

Thank you @primordial I found a solution. I was really a problem with autoload files. The kind i tried to load the extension works, but it doesn't generate an entry in autoload files. For my other packages it worked. Its a special thing for Cartalyst Platform to load packages in other directories as vendor. To generate also autoload entries I had to change the composer code to ...

{ "type": "vcs", "url": "https://github.com/pixelairport/platform-api2.git" }

... like in this post: https://github.com/composer/composer/issues/6846

Please or to participate in this conversation.