[英]UnexpectedValueException Could not parse version constraint when trying to instal laravelcollective
I am new to laravel and I am trying to install laravelcollective . 我是laravel的新手,我正在尝试安装laravelcollective 。 I am just following to documentation here and I am using this from my project directory:
我只是想以文件在这里 ,我使用这个从我的项目目录:
composer require "laravelcollective/html":"^5.4.0"
Unfortunately, immediately after I press ented I get the following error : 不幸的是,在我按下后立即出现以下错误:
[UnexpectedValueException] Could not parse version constraint :5.4.0: Invalid version string ":5.4.0"
[UnexpectedValueException]无法解析版本约束:5.4.0:无效的版本字符串“:5.4.0”
I just don't know how to troubleshoot this. 我只是不知道如何解决这个问题。 I didn't find much on google and this combined with my lack of experience with laravel leaves me stuck.
我在google上找不到太多东西,这与我在laravel上缺乏经验相结合,让我陷入困境。
Can someone help? 有人可以帮忙吗?
You can add it manually in composer.json
then use composer update
. 您可以在
composer.json
手动添加它,然后使用composer update
。
Just add "laravelcollective/html": "5.4.*",
under the row with "laravel/framework":"5.4.*",
只需添加
"laravelcollective/html": "5.4.*",
在"laravel/framework":"5.4.*",
行下"laravel/framework":"5.4.*",
Like this : 像这样 :
"require": {
"php": ">=7.0.0",
"fideloper/proxy": "~3.3",
"laravel/framework": "5.4.*",
"laravelcollective/html": "5.4.*", <-- Add this row
"laravel/tinker": "~1.0"
},
You should never run composer update
without any arguments if you do not want to update all your dependencies. 如果您不想更新所有依赖项,则不应在没有任何参数的情况下运行
composer update
。
In your case, the issue probably is that the ^
character is already interpreted by your shell before the argument is passed to Composer. 在您的情况下,问题可能是在将参数传递给Composer之前,shell已经解释了
^
字符。 This could possibly be solved by using single quotes instead of double quotes: 这可以通过使用单引号而不是双引号来解决:
composer require 'laravelcollective/html:^5.4.0'
When you used the 5.4.*
constraint as suggested in one of the comments above, you added a space after the colon which leads to Composer interpreting the version constraint as a package name. 当您使用上面其中一条评论中建议的
5.4.*
约束时,您在冒号后面添加了一个空格,这会导致Composer将版本约束解释为包名称。 The right command would have been this: 正确的命令是这样的:
composer require "laravelcollective/html":"5.4.*"
composer require "laravelcollective/html ^5.4.0"
为我工作!
In my case, I was using Laravel 5.7 and kept getting an error when trying to install the Laravel collective. 就我而言,我正在使用Laravel 5.7并在尝试安装Laravel集合时不断出错。
You can use this command without specifying any version: 您可以使用此命令而无需指定任何版本:
composer require 'laravelcollective/html'
It worked for me. 它对我有用。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.