Reputation: 3918
(Before I begin, I have seen the two identical questions, both set the repository type to "package" which is NOT my issue here.)
I have created my first composer packages and am trying to include them in another project. However, the autoload settings I have created are not being added to the appropriate autoload file.
Here is the dependencies composer.json:
{
"name": "company/authentication",
"description": "User authentication",
"require": {},
"require-dev": {
"phpunit/phpunit": "4.5.*"
},
"autoload": {
"psr-4": {
"Company\\Authentication\\": "src/"
}
}
}
And here is the parent composer.json where I am including the above file:
{
"config": {
"vendor-dir": "_framework/vendor",
"secure-http": false
},
"repositories": [
{
"type": "composer",
"url": "composer.<REDACTED>.com"
}
],
"require-dev": {
"phpunit/phpunit": "4.5.*",
"phpunit/dbunit": ">=1.2",
"phpunit/phpunit-selenium": ">=1.2"
},
"require": {
"company/authentication": "1.0.*"
}
}
And finally, this is the autogenerated autoload_psr4 file:
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname(dirname($vendorDir));
return array(
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
);
And as it is asked below, I am not using Satis, instead I hand created a basic repository. This is my packages.json file for my repository:
{
"packages": {
"company/authentication": {
"1.0.0": {
"name": "company/authentication",
"version": "1.0.0",
"dist": {
"url": "http://composer.company.com/repo/authentication-1.0.0.zip",
"type": "zip"
}
}
},
etc...
And here is my composer.lock file:
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "f67a284cbfcb2cf6ae3765266015710b",
"content-hash": "57c9067e1b3a3bb7fef45eeabb928ffd",
"packages": [
{
"name": "company/authentication",
"version": "1.0.0",
"dist": {
"type": "zip",
"url": "http://composer.company.com/repo/authentication-1.0.0.zip",
"reference": null,
"shasum": null
},
"type": "library"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}
Upvotes: 0
Views: 854
Reputation: 3918
Thanks for looking. I found the issue was that the dependencies and autoload settings need to be in the composer.json file of the library and in the packages.json file on the repository server. It seems that the composer.json file contents of imported dependencies are ignored by composer.
This completely confuses me - why does composer look at the server meta information to know what the dependencies are, instead of the composer.json file that is embedded with the code?
Upvotes: 2
Reputation: 36924
You probably need to update your packages info. You can do that, as the documentation suggest, with:
php bin/satis build <configuration file> <build dir>
Example:
php bin/satis build satis.json web/
You should do this every time you change something of yours composer.json
files.
Upvotes: 1