Composer require-dev autoload from a package not added to project autoload

I made a compositing 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 the composer install by forcing 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 works great here. Then I add the package to the Satis server.

In my composer.json project 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 using dev param on my project. The package is installed in the "vendor / myvendor / mypackage" folder and I know the DEV version is installed because there is a "test" folder there (test folder excluded (archive excluded) on stable versions).

But the following line is missing in 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'm wondering why my package namespace is not added to the autoloader. Can someone please explain?

+3


source to share


1 answer


autoload-dev

and require-dev

only work for root (btw, dev by default). The dev options are only useful when you want to develop a package. Once you need a package in another project, you no longer want to develop the package, but another project.



+3


source







All Articles