我用作曲家创建了我的自定义php库。此库的composer.json
如下所示:
{
"name": "singboard/platform-fetcher",
"description": "Fetch reviews from third part platforms.",
"license": "proprietary",
"version": "0.1.0-dev",
"authors": [
[...]
],
"type": "library",
"require": {
[...]
},
"require-dev": {
[...]
},
"autoload": {
"psr-4": {
"Singboard\PlatformFetcher\": "src/"
}
}
}
作曲家库的文件夹结构如下:
├── composer.json
├── composer.lock
└── src
└── FacebookFetcher.php
现在我已经把这个库包含在我的laravel项目中。在我的 laravel 项目的composer.json
中,我添加了以下内容:
"repositories": [
{
"type": "package",
"package": {
"name": "singboard/platform-fetcher",
"version": "0.1.0-dev",
"type": "library",
"source": {
"url": "xxx-xxx",
"type": "git",
"reference": "master"
}
}
}
],
"require": {
"singboard/platform-fetcher": "0.1.0-dev"
},
问题是当我尝试调用FacebookFetcher.php
类时,我收到消息Class 'SingboardPlatformFetcherFacebookFetcher' not found
。问题出在哪里?
如作曲家文档中所报告的那样,这不是包含自定义远程库的正确方法。您应该通过以下方式实现您的库:
{
"require": {
"vendor/my-private-repo": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "git@bitbucket.org:vendor/my-private-repo.git"
}
]
}