(在我开始之前,我已经看到了两个相同的问题,都将存储库类型设置为"包",这不是我在这里的问题。
我已经创建了我的第一个作曲家包,并尝试将它们包含在另一个项目中。但是,我创建的自动加载设置未添加到相应的自动加载文件中。
以下是依赖项 composer.json:
{
"name": "company/authentication",
"description": "User authentication",
"require": {},
"require-dev": {
"phpunit/phpunit": "4.5.*"
},
"autoload": {
"psr-4": {
"Company\Authentication\": "src/"
}
}
}
这是父作曲家.json,我在其中包含上述文件:
{
"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.*"
}
}
最后,这是自动生成的autoload_psr4文件:
// 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'),
);
正如下面所问的,我没有使用 Satis,而是手动创建了一个基本的存储库。这是我的存储库的 packages.json 文件:
{
"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...
这是我的作曲家.lock文件:
{
"_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": []
}
感谢您的查看。我发现问题是依赖项和自动加载设置需要位于库的 composer.json 文件和存储库服务器上的 packages.json 文件中。似乎导入的依赖项的 composer.json 文件内容被作曲家忽略了。
这完全让我感到困惑 - 为什么作曲家查看服务器元信息以了解依赖项是什么,而不是嵌入代码的 composer.json 文件?
您可能需要更新包信息。正如文档所建议的那样,您可以使用以下方法执行此操作:
php bin/satis build <configuration file> <build dir>
例:
php bin/satis build satis.json web/
每次更改composer.json
文件的某些内容时,都应该执行此操作。