我得到“您的要求无法解决为一组可安装的软件包。”当我运行作曲家更新
Posted
技术标签:
【中文标题】我得到“您的要求无法解决为一组可安装的软件包。”当我运行作曲家更新【英文标题】:I get "Your requirements could not be resolved to an installable set of packages." when I run composer update 【发布时间】:2016-04-08 15:43:27 【问题描述】:我使用 laravel 5.2 编写了一个应用程序。这个应用程序有模块/包。所有软件包都将位于名为modules
的文件夹中。
我的第一个包位于名为modules/Mikea/Surveys
的文件夹中。 Mikea
是供应商名称,Surveys
是模块/包名称。每个包都有它自己的composer.json
文件,它允许我使用它自己的作曲家配置来配置每个包。 (我目前有一个包裹,但以后可以有更多)
在我的主 composer.json 文件中,我使用 "path" 在存储库部分输入,就像您在以下 composer.json 文件中看到的那样
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require":
"php": ">=5.5.9",
"laravel/framework": "5.2.*",
"laravelcollective/html": "5.2.x-dev",
"mikea/surveys": "*"
,
"require-dev":
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"symfony/dom-crawler": "~3.0",
"symfony/css-selector": " ~3.0"
,
"repositories": [
"type": "path",
"url": "modules/Mikea/Surveys"
],
"autoload":
"classmap": [
"database"
],
"psr-4":
"App\\": "app/",
"Modules\\": "modules/"
,
"autoload-dev":
"classmap": [
"tests/TestCase.php"
]
,
"scripts":
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
]
,
"config":
"preferred-install": "dist"
在第二个 composer.json 文件“包文件”中我有以下内容
"name": "mikea/surveys",
"type": "library",
"description": "Survey System",
"authors": [
"name": "Mike A",
"email": "some@email.com"
],
"repositories": [
"type": "package",
"package":
"name": "mikea/surveys",
"version": "0.1.0",
"source":
"type": "path",
"url": "modules/Mikea/Surveys"
],
"require":
"php": ">=5.4.0"
,
"autoload":
"classmap": [
"database/migrations",
"database/seeds"
],
"psr-4":
"mikea\\Surveys\\": "src/"
,
"minimum-stability": "dev",
"prefer-stable": true
当我运行composer update
时出现以下错误
F:\xampp\htdocs\proj>composer update
> php artisan clear-compiled
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package mikea/surveys could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
我在这里做错了什么?为什么会出现此错误?
【问题讨论】:
您的文件系统上是否存在modules/Mikea/Surveys
? getcomposer.org/doc/05-repositories.md#path
@ceejayoz 是的。它位于app
、databases
....文件夹旁边
尝试./modules/Mikea/Surveys
,并确保modules/Mikea/Surveys/composer.json
是有效的JSON。
@ceejayoz 我应该在哪里使用 ./modules/Mikea/Surveys
我尝试在存储库 url 中使用它,但仍然出现同样的错误?
【参考方案1】:
我相信我想通了。
我必须像这样在我的第二个composer.json
文件中添加一个“版本”标签。至少添加“版本”可以让我没有错误地运行命令
"name": "mikea/surveys",
"type": "library",
"description": "Survey System",
"version": "0.1.0",
"authors": [
"name": "Mike A",
"email": "some@email.com"
],
"require":
"php": ">=5.4.0"
,
"autoload":
"classmap": [
"database/migrations",
"database/seeds"
],
"psr-4":
"mikea\\Surveys\\": "src/"
,
"minimum-stability": "dev",
"prefer-stable": true
【讨论】:
以上是关于我得到“您的要求无法解决为一组可安装的软件包。”当我运行作曲家更新的主要内容,如果未能解决你的问题,请参考以下文章
CakePHP 4.x Authentication 2.x - 安装失败。您的要求无法解决为一组可安装的软件包