Composer生成错误的大写命名空间

When pulling in a self-made composer package, the files that get pulled in have different namespace capitalization than the the source code.


The package source code on GitHub

Source composer.json code:

"name": "bsapaka/metattribute",
"autoload": {
        "psr-4": {
            "Bsapaka\\Metattribute\\": "src/"
        }
    },

Source namespace:

namespace Bsapaka\Metattribute;


The code that appears when pulled into project from Packagist

The line that composer generates in autoload_psr4.php:

'bsapaka\\metattribute\\' => array($vendorDir . '/bsapaka/metattribute/src'),

The namespace appearing in the vendor files:

namespace bsapaka\Metattribute;

The exception when trying to use it:

Class 'bsapaka\Metattribute\AttributeList' not found


I have tried changing the source code capitalizations. All upper case, all lower case, one upper one lower, etc. Each time, the psr4 path and the class namespaces are never the same, and the exception persists.

I pulled down a copy of your library and created a PHPUnit test. I could not reproduce your problem. It looks like you got it resolved? You are now using namespace Bsapaka\Metattribute.

In Tests\AttributeTest.php:

<?php

class AttributeTest extends PHPUnit_Framework_TestCase
{
    public function testName()
    {
        $attribute = new \Bsapaka\Metattribute\Attribute("Elvis");
        $this->assertEquals("Elvis", $attribute->getName());
    }
}

To get the above to work, composer.json now includes:

"require-dev": {
    "phpunit/phpunit": "~4.0"
}

And launched via: vendor/bin/phpunit tests/AttributeTest.php