UnexpectedValueException Could not parse version constraint when trying to instal laravelcollective

17,692

Solution 1

You can add it manually in composer.json then use composer update.

Just add "laravelcollective/html": "5.4.*", under the row with "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"
    },

Solution 2

You should never run composer update without any arguments if you do not want to update all your dependencies.

In your case, the issue probably is that the ^ character is already interpreted by your shell before the argument is passed to Composer. 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. The right command would have been this:

composer require "laravelcollective/html":"5.4.*"

Solution 3

composer require "laravelcollective/html ^5.4.0"

Worked for me!

Solution 4

In my case, I was using Laravel 5.7 and kept getting an error when trying to install the Laravel collective.

You can use this command without specifying any version:

composer require 'laravelcollective/html'

It worked for me. :)

Share:
17,692
incense_stick
Author by

incense_stick

Updated on June 26, 2022

Comments

  • incense_stick
    incense_stick almost 2 years

    I am new to laravel and I am trying to install 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"

    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.

    Can someone help?