简体   繁体   English

UnexpectedValueException尝试安装laravelcollective时无法解析版本约束

[英]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.

相关问题 UnexpectedValueException 无法解析版本约束 mybranch:版本字符串“mybranch”无效 - UnexpectedValueException Could not parse version constraint mybranch: Invalid version string "mybranch" 作曲者-[UnexpectedValueException]无法解析版本约束README.md:无效的版本字符串“ README.md” - composer - [UnexpectedValueException] Could not parse version constraint README.md: Invalid version string “README.md” 无法解析版本约束 - Could not parse version constraint 在SLIM monolog中创建日志文件时出现UnexpectedValueException - UnexpectedValueException when create a log file in SLIM monolog 创建新项目时出现 UnexpectedValueException Symfony - UnexpectedValueException when creating a new Symfony project 如何将CKEditor 4.2版安装到YII - How to instal CKEditor Version 4.2 to YII 尝试创建自定义验证约束时出现UnexpectedTypeException - UnexpectedTypeException when trying to create a custom validation constraint Laravel 5.2:违反完整性约束:1452无法添加或更新子行:外键约束失败,不使用laravelcollective - Laravel 5.2: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails, without using a laravelcollective Laravel 集体日期时间 - LaravelCollective DatetTime SQL错误尝试添加相关产品完整性约束违规时: - SQL ERROR When trying to add related product Integrity constraint violation:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM