简体   繁体   中英

Composer require-dev autoload from package not added to project's autoload

I have made a composer package with the following settings in the composer.json file:

"autoload": {
    "psr-4": {
        "MyVendor\\MyPackage\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Test\\Unit\\MyProject\\MyPackage\\": "test/unit"
    }
},

If I run composer install, enforcing dev param, and I get the following "autoload_psr4.php" file:

<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Test\\Unit\\MyVendor\\MyPackage\\' => array($baseDir . '/test/unit'),
    'MyVendor\\MyPackage\\' => array($baseDir . '/src'),
);

So basically, everything is working fine here. Then, I add the package to a Satis server.

In my project's composer.json file, I add the following line:

"require": {
    "myvendor/mypackage": "1.0.*@dev",
    "symfony/http-foundation": "2.5.*",
    "symfony/http-kernel": "2.5.*"
}

Once again, I run composer install, enforcing dev param, in my project. The package gets installed in "vendor/myvendor/mypackage folder" and I know the DEV version is installed because the "test" folder is there (test folder is excluded (archive exclude) on stable releases).

But, the following line is missing from the "autoload_psr4.php" file

'Test\\Unit\\MyVendor\\MyPackage\\' => array($baseDir . '/test/unit'),

Here is the composer install command I used:

composer install --dev -d /var/www/myproject

Basically, I am wondering why my package's dev namespace is not added to the autoloader. Can someone explain?

autoload-dev and require-dev both work for the root only (btw, dev is the default). The dev versions are only usefull when you want to develop the package. As soon as you require the package in another project, you no longer want to develop the package, but the other project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM