Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mstdmstd's avatar

I got composer install error under php 7.4

Hello, I try to run laravel 7 under php 7.4 (I worked under php 7.3 before) and I got error:

$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)

In ComposerRepository.php line 637:
                                                                                                                                                                   
  Could not load package mews/purifier in http://packagist.org: [UnexpectedValueException] Could not parse version constraint ~4.*: Invalid version string "~4.*"  
                                                                                                                                                                   

In VersionParser.php line 485:
                                                                          
  Could not parse version constraint ~4.*: Invalid version string "~4.*"  

In composer.json:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.2.5",
        "cartalyst/sentinel": "^4.0",
        "cviebrock/eloquent-sluggable": "^7.0",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^1.0",
        "guzzlehttp/guzzle": "^6.3",
        "illuminate/database": "^7.27",
        "illuminate/events": "^7.27",
        "intervention/image": "dev-master",
        "laravel/framework": "^7.0",
        "laravel/tinker": "^2.0",
        "livewire/livewire": "^1.3",
        "mews/purifier": "^3.2",
        "prettus/l5-repository": "^2.6",
        "realrashid/sweet-alert": "^3.1",
        "spatie/laravel-image-optimizer": "^1.6",
        "spatie/laravel-medialibrary": "^7.19",
        "symfony/http-foundation": "^5.1",
        "wboyz/laravel-enum": "^0.2.1"
    },
    "require-dev": {
        "facade/ignition": "^2.0",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^4.1"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "files": [
            "app/library/helper.php"
        ],

        "psr-4": {
            "App\": "app/",
            "Modules\": "Modules/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Also I removed composer.lock and run again composer update with same results

Is syntax of this file wrong? What have I to change in it?

Thanks!

0 likes
5 replies
tykus's avatar

Well, ~4.* is not a valid version range - it should be ~4 or ~4.0

mstdmstd's avatar

I modified line :

      "mews/purifier": "~4.0",

and again got error :

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)

In ComposerRepository.php line 637:
                                                                                                                                                                   
  Could not load package mews/purifier in http://packagist.org: [UnexpectedValueException] Could not parse version constraint ~4.*: Invalid version string "~4.*"  
                                                                                                                                                                   

In VersionParser.php line 485:
                                                                          
  Could not parse version constraint ~4.*: Invalid version string "~4.*"

?

tykus's avatar

There is no version 4 for that package. I don't believe that the mews/purifier package version is the issue, rather another dependency.

mstdmstd's avatar
  1. What could you advice to fix it ? 2) Are there some replacement of mews/purifier ?
isaqqer's avatar

remove this line "mews/purifier": "^3.2",

then in terminal write

composer require mews/purifier

Please or to participate in this conversation.