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
andrequire-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.