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

shariff's avatar
Level 50

Unable to run 'composer update' or 'composer install' command

Hi

I recently download xampp for windows. After installing xampp I shifted all my project to htdocs folder. while running project I am getting this error

Declaration of Doctrine\DBAL\Driver\PDOConnection::query() must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed ...$fetchModeArgs)

After some research I came to know I should update my composer.json to latest version. I tried running

composer install 
composer update 

after running this I am getting error like this


Problem 1
    - Root composer.json requires php ^7.2.5 but your php version (8.0.2) does not satisfy that requirement.
  Problem 2
    - asm89/stack-cors is locked to version v2.0.1 and an update of this package was not requested.
    - asm89/stack-cors v2.0.1 requires php ^7.0 -> your php version (8.0.2) does not satisfy that requirement.
  Problem 3
    - doctrine/dbal is locked to version 2.10.2 and an update of this package was not requested.
    - doctrine/dbal 2.10.2 requires php ^7.2 -> your php version (8.0.2) does not satisfy that requirement.
  Problem 4
    - dragonmantank/cron-expression is locked to version v2.3.0 and an update of this package was not requested.
    - dragonmantank/cron-expression v2.3.0 requires php ^7.0 -> your php version (8.0.2) does not satisfy that requirement.
  Problem 5
    - laravel/framework is locked to version v7.24.0 and an update of this package was not requested.
    - laravel/framework v7.24.0 requires php ^7.2.5 -> your php version (8.0.2) does not satisfy that requirement.

like this I am getting 50 errors related to all packages different versions. I tried everything but unable to do. my composer.json

"require": {
        "php": "^7.2.5",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^6.3",
        "laravel/framework": "^7.22.2",
        "laravel/tinker": "^2.0",
        "laravel/ui": "2.0",
        "laravelcollective/html": "^6.1",
        "livewire/livewire": "^2.2",
        "spatie/laravel-medialibrary": "^8.0.0",
        "spatie/laravel-permission": "^3.13",
        "tymon/jwt-auth": "^1.0",
        "yajra/laravel-datatables": "1.5"
    },
    "require-dev": {
        "facade/ignition": "^2.0",
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
    },

please help to solve this problem.

thank you

0 likes
12 replies
shariff's avatar
Level 50

@jlrdw I tried that also. And I am using latest version of composer

jlrdw's avatar

@siangboon @shariff I also just read that issue, but what is weird the composer.json already has

    "require": {
        "php": "^7.3|^8.0",

Unless you modified it.

I just did a fresh install, and all worked.

@shariff are you pointing composer to correct php version? Do a fresh composer install with the GUI installer, it will ask you for the correct PHP.exe to use.

shariff's avatar
Level 50

@jlrdw where to check? whether the composer is pointing to which version.

shariff's avatar
Level 50

@siangboon okay bro thanks for the link. I tried that solution now I am getting this error when I run composer install

 Problem 1
    - spatie/laravel-medialibrary[8.0.0, ..., v8.x-dev] require php ^7.4 -> your php version (7.2.5; overridden via config.platform, actual: 8.0.2) does not satisfy that requirement.
    - Root composer.json requires spatie/laravel-medialibrary ^8.0.0 -> satisfiable by spatie/laravel-medialibrary[8.0.0, ..., v8.x-dev].
jlrdw's avatar

Reinstall and tell it the correct php.exe. I have no idea if you have more than one php installed on your machine.

Again, I just did a test install of "latest" laravel, no problems encountered.

2 likes
shariff's avatar
Level 50

@jlrdw okay thanks for the help I'll try and let you know. For creating new application I am not getting any error only for old projects I am facing this issue.

jlrdw's avatar
jlrdw
Best Answer
Level 75

Usually problems like that are dependency related, you have to (even if manually) check dependencies.

I normally always run:

composer clearcache 
composer selfupdate

If still having problems:

Backup the lock file. Delete the lock file. Try again.

If that doesn't work you have a mismatched dependency, you need to check the various GitHub repositories and track down your mismatched dependency.

Just an extreme example:

Laravel 4.1 would not match with the framework 8.0.

So you need to go to the various composer.json files and make sure the dependencies are correct.

    "require": {
        "php": "^7.3|^8.0",
        "fideloper/proxy": "^4.4",      here  here     
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.12",
        "laravel/tinker": "^2.5"
    },

Pretend in the above your composer.json had "fideloper/proxy": "^3.0", so you would need to fix that.

That was just another example.

3 likes
shariff's avatar
Level 50

@jlrdw @siangboon Thank you very very much for helping. Finally after following this link https://github.com/composer/composer/issues/9529 I can able to run the application without any errors. when I run composer update I am getting errors

Problem 1
    - spatie/laravel-medialibrary[8.0.0, ..., v8.x-dev] require php ^7.4 -> your php version (7.2.5; overridden via config.platform, actual: 8.0.2) does not satisfy that requirement.
    - Root composer.json requires spatie/laravel-medialibrary ^8.0.0 -> satisfiable by spatie/laravel-medialibrary[8.0.0, ..., v8.x-dev].

by seeing the error I think I should change all the version of packages based on requirement.

thank you once again

Please or to participate in this conversation.