覆盖Composer自动加载器

Background

I'm developing a series of websites which share a common engine. Something very similar to StackExchange's network of websites. Every webiste is a separate Symfony2 installation on a different Git repository, with a dependency to the engine, which is also placed on a separate repository.

 "requires": {
     ...
     "my-platform/core": "dev-master"
 }

I'm still in the early stage of development, so I'd like not have to use composer update everytime I change something in the core repository. It seems that Composer has a right tool to solve this problem but it doesn't want to work properly.

My directory structure:

Workspace
    MyPlatformCore
        src
            MyPlatform
                Core
                    SomeClass.php
        composer.json
    MyWebsiteAAA
        app
        src
        vendor
        web
        composer.json
    MyWebsiteBBB
        app
        src
        vendor
        web
        composer.json

Autoload section from composer.json from every MyWebsiteXXX repository:

"autoload": {
    "psr-0": {
        "MyPlatform": "../MyPlatformCore/src"
    }
},

Problem

If i run php composer.phar dumpautoload --optimize from MyWebsiteXXX it generates files of autoloader with wrong paths. File vendor/composer/autoload_classmap.php contains:

'MyPlatform\\Core\\...' => $vendorDir . '/myplatform/core/src/MyPlatform/Core/...php',

while it should contain:

'MyPlatform\\Core\\...' => $vendorDir . '/../MyPlatformCore/src/MyPlatform/Core/...php',

P.S. Workspace\MyPlatformCore is in fact a symlink, but it should matter, isn't it?

Composer does not fit your current phase of work.

Having a working PSR-0 autoloader for your core classes will make them available to your other code. Adding this autoloader to the Composer autoloader should work, but I think it is better to integrate your core "code in progress" via symlink instead of constantly composer-updating it.

The real benefit would be with an existing core codebase in several tagged versions, and your multiple websites using defined versions that differ from each other. You would only work on the core if there are features to be added or bugs fixed. The daily work would go into any of the websites, which might include updating this websites core files when it is time to do so.