无法使用 Composer 要求包
Failed to require a package using Composer
我想在我的项目中需要这个包:
lucianocosta/jquery.mtz.monthpicker
所以我将它添加到我的 composer.json 文件中:
{
"name": "yiisoft/yii2-app-advanced",
"description": "Yii 2 Advanced Application Template",
"keywords": ["yii2", "framework", "advanced", "application template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*",
"google/apiclient": "1.0.*@beta",
"asimlqt/php-google-spreadsheet-client": "2.2.*",
"phpoffice/phpexcel": "*",
"lucianocosta/jquery.mtz.monthpicker": "dev-master"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*"
},
"config": {
"process-timeout": 1800
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
然后我 运行 composer update
命令但我收到了这条消息:
无法将您的要求解析为一组可安装的软件包。
问题 1
- 请求的包 lucianocosta/jquery.mtz.monthpicker 在任何版本中都找不到,包名可能有错别字。
潜在原因:
- 包名中的错字
- 根据您的最低稳定性设置,该软件包没有足够稳定的版本
在不改变任何最低稳定性设置的情况下,我是否可以成功地要求这个包?
问题是请求的包不是作曲家包(它没有 composer.json
)并且无法通过 packagist.org 存储库获得。这意味着这个包的作者没有提供对 composer 的支持。
A repository is a package source. It's a list of packages/versions. Composer will look in all your repositories to find the packages your project requires.
By default only the Packagist repository is registered in Composer. You can add more repositories to your project by declaring them in composer.json.
但是可以在 composer.json
中注册新的存储库。以下代码为 lucianocosta/jquery.mtz.monthpicker
注册了一个存储库,并使用 RobLoach/component-installer
将它们从 /vendor
文件夹中取出。如果不需要,只需删除 package
部分中的 extra
和 require
部分即可。
"repositories": [
{
"type": "package",
"package": {
"name": "lucianocosta/jquery.mtz.monthpicker",
"version": "1.0",
"type": "component",
"dist": {
"url": "https://github.com/lucianocosta/jquery.mtz.monthpicker/archive/master.zip",
"type": "zip"
},
"extra": {
"component": {
"scripts": [
"jquery.mtz.monthpicker.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
}
],
"require": {
"lucianocosta/jquery.mtz.monthpicker": "1.*"
},
您需要的包不是 Composer 包,因为 Composer 是 PHP 包管理器,而您想使用的包仅用于前端。
前端包由 Bower 维护,但 Yii 建议您 install composer-assets-plugin
which can handle Bower packages through composer.json
and then you don't need to maintain them in separate bower.json
。
然后您需要找到正确的 Bower 包名称。你可以通过网站 http://bower.io/search/?q=monthpicker
或者如果你安装了 Bower 你可以像这样从命令行搜索这个包:
bower search jquery.mtz.monthpicker
Search results:
monthpicker git://github.com/lucianocosta/jquery.mtz.monthpicker.git
当您有了包名(在本例中为 monthpicker
)时,您只需将其添加到 composer.json
的 require
部分,并以 bower-asset/
为前缀(在这种情况下 bower-asset/monthpicker
.
这是您的 require
部分的固定版本:
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*",
"google/apiclient": "1.0.*@beta",
"asimlqt/php-google-spreadsheet-client": "2.2.*",
"phpoffice/phpexcel": "*",
"bower-asset/monthpicker": "dev-master"
},
我想在我的项目中需要这个包: lucianocosta/jquery.mtz.monthpicker
所以我将它添加到我的 composer.json 文件中:
{
"name": "yiisoft/yii2-app-advanced",
"description": "Yii 2 Advanced Application Template",
"keywords": ["yii2", "framework", "advanced", "application template"],
"homepage": "http://www.yiiframework.com/",
"type": "project",
"license": "BSD-3-Clause",
"support": {
"issues": "https://github.com/yiisoft/yii2/issues?state=open",
"forum": "http://www.yiiframework.com/forum/",
"wiki": "http://www.yiiframework.com/wiki/",
"irc": "irc://irc.freenode.net/yii",
"source": "https://github.com/yiisoft/yii2"
},
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*",
"google/apiclient": "1.0.*@beta",
"asimlqt/php-google-spreadsheet-client": "2.2.*",
"phpoffice/phpexcel": "*",
"lucianocosta/jquery.mtz.monthpicker": "dev-master"
},
"require-dev": {
"yiisoft/yii2-codeception": "*",
"yiisoft/yii2-debug": "*"
},
"config": {
"process-timeout": 1800
},
"extra": {
"asset-installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
然后我 运行 composer update
命令但我收到了这条消息:
无法将您的要求解析为一组可安装的软件包。
问题 1 - 请求的包 lucianocosta/jquery.mtz.monthpicker 在任何版本中都找不到,包名可能有错别字。
潜在原因:
- 包名中的错字
- 根据您的最低稳定性设置,该软件包没有足够稳定的版本
在不改变任何最低稳定性设置的情况下,我是否可以成功地要求这个包?
问题是请求的包不是作曲家包(它没有 composer.json
)并且无法通过 packagist.org 存储库获得。这意味着这个包的作者没有提供对 composer 的支持。
A repository is a package source. It's a list of packages/versions. Composer will look in all your repositories to find the packages your project requires.
By default only the Packagist repository is registered in Composer. You can add more repositories to your project by declaring them in composer.json.
但是可以在 composer.json
中注册新的存储库。以下代码为 lucianocosta/jquery.mtz.monthpicker
注册了一个存储库,并使用 RobLoach/component-installer
将它们从 /vendor
文件夹中取出。如果不需要,只需删除 package
部分中的 extra
和 require
部分即可。
"repositories": [
{
"type": "package",
"package": {
"name": "lucianocosta/jquery.mtz.monthpicker",
"version": "1.0",
"type": "component",
"dist": {
"url": "https://github.com/lucianocosta/jquery.mtz.monthpicker/archive/master.zip",
"type": "zip"
},
"extra": {
"component": {
"scripts": [
"jquery.mtz.monthpicker.js"
]
}
},
"require": {
"robloach/component-installer": "*"
}
}
}
],
"require": {
"lucianocosta/jquery.mtz.monthpicker": "1.*"
},
您需要的包不是 Composer 包,因为 Composer 是 PHP 包管理器,而您想使用的包仅用于前端。
前端包由 Bower 维护,但 Yii 建议您 install composer-assets-plugin
which can handle Bower packages through composer.json
and then you don't need to maintain them in separate bower.json
。
然后您需要找到正确的 Bower 包名称。你可以通过网站 http://bower.io/search/?q=monthpicker
或者如果你安装了 Bower 你可以像这样从命令行搜索这个包:
bower search jquery.mtz.monthpicker
Search results:
monthpicker git://github.com/lucianocosta/jquery.mtz.monthpicker.git
当您有了包名(在本例中为 monthpicker
)时,您只需将其添加到 composer.json
的 require
部分,并以 bower-asset/
为前缀(在这种情况下 bower-asset/monthpicker
.
这是您的 require
部分的固定版本:
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*",
"yiisoft/yii2-swiftmailer": "*",
"yiisoft/yii2-gii": "*",
"yiisoft/yii2-faker": "*",
"google/apiclient": "1.0.*@beta",
"asimlqt/php-google-spreadsheet-client": "2.2.*",
"phpoffice/phpexcel": "*",
"bower-asset/monthpicker": "dev-master"
},