我正在使用Symfony 2创建一个网站,我在安装KnpMenuBundle
时遇到了很大问题。我读了很多关于这些问题的文章。我尝试了很多变种如何解决这个问题。但没有任何帮助。
这是我的composer.json
文件:
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"doctrine/data-fixtures" : "dev-master",
"knplabs/knp-paginator-bundle": "dev-master",
"apy/datagrid-bundle": "2.2.*@dev",
"friendsofsymfony/user-bundle": "*",
"jms/security-extra-bundle": "1.4.x-dev",
"knplabs/knp-menu-bundle":"dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.2-dev"
}
}
}
这是我在控制台中得到的内容
D:\Work\YouMustKnowIt_portal\Symfony>php composer.phar update
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
- Installation request for knplabs/knp-menu-bundle dev-master -> satisfiable
by knplabs/knp-menu-bundle[dev-master].
- knplabs/knp-menu-bundle dev-master requires knplabs/knp-menu 2.0.* -> no m
atching package found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
problems.
答案 0 :(得分:1)
包knplabs/knp-menu-bundle
要求knplabs/knp-menu
版本为2.0.*
。但是这个依赖项没有标记的2.0版本。实现此目的的最简单方法是使用依赖项的开发版本。只需将其添加到您的要求中:
"knplabs/knp-menu": "2.0.*@dev"
然后你应该得到以下输出(commit-sha可能不同):
- Installing knplabs/knp-menu (dev-master 5cf5ab4)
Cloning 5cf5ab4948d8c573f260e2b612bfc9721da1c892
- Installing knplabs/knp-menu-bundle (dev-master a4d6b33)
Cloning a4d6b338e47920880d1c972143ef39ffb564665f
最后一步是在app/AppKernel.php
:
public function registerBundles()
{
$bundles = array(
// ...
new Knp\Bundle\MenuBundle\KnpMenuBundle(),
);
// ...
}