6

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?

incense_stick
  • 478
  • 1
  • 6
  • 14

4 Answers4

4

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"
    },
Thomas Rollet
  • 1,573
  • 4
  • 19
  • 33
  • 2
    You should never run `composer update` without any arguments if you do not want to update **all** your dependencies. – xabbuh Nov 14 '17 at 11:11
3

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.*"
xabbuh
  • 5,801
  • 16
  • 18
  • So, do you think that by running composer update without arguments I might have ruined something else? By the way, I tried all variations and nothing was working. – incense_stick Nov 14 '17 at 11:34
  • The single quotes made it happen for me – Jepzen Apr 30 '18 at 09:54
  • Excellent call regarding the space after the colon. I had inadvertently added a space after the colon when inline-aliasing, e.g., `composer require "laravel/framework": "dev-pgsql-fixes as v5.8.35"`, and this error resulted. – Ben Johnson Sep 19 '19 at 16:37
2
composer require "laravelcollective/html ^5.4.0"

Worked for me!

Bla Bla
  • 49
  • 1
  • 10
2

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. :)

rob006
  • 21,383
  • 5
  • 53
  • 74
mikejay
  • 31
  • 1
  • 3