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

warpig's avatar
Level 12

Upgrading PHP version used by composer, dependency

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.25

I thought I had 7.4 version of PHP when I created this Laravel project but where does Composer exactly verifies the version it uses for dependencies? I already changed this inside the composer.json file:

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

to

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

Then ran this into the terminal: composer update php --with-all-dependencies

But the warning stays the same, actually this is part of the output:

Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating optimized autoload files

I know the package is installed because it shows it afterwards, I don't get how to dig into that PHP version. Please help!

0 likes
25 replies
warpig's avatar
Level 12

composer check-platform-reqs

Checking platform requirements for packages in the vendor dir
ext-dom        20031129    success  
ext-fileinfo   7.4.14      success  
ext-filter     7.4.14      success  
ext-json       7.4.14      success  
ext-libxml     7.4.14      success  
ext-mbstring   7.4.14      success  
ext-openssl    7.4.14      success  
ext-pcre       7.4.14      success  
ext-phar       7.4.14      success  
ext-tokenizer  7.4.14      success  
ext-xml        7.4.14      success  
ext-xmlwriter  7.4.14      success  
lib-pcre       10.36       success  
php            7.4.14      success 
RahulKmOfficial's avatar

You don't need to make changes in composer.json revert that.

Insted check your php cli version for example if you are in linux just type

 php -v

and see output. i think your php cli is 7.3.25 just updating that to 7.4* should solve your issue. still you want you can delete /vendor & can run

 composer install
warpig's avatar
Level 12

Strange, php -v outputs:

PHP 7.4.14 (cli) (built: Jan  5 2021 14:30:27) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies
RahulKmOfficial's avatar

just cut paste vendor directory to somewhere else in case you need them. then try to run

 composer update && composer install
warpig's avatar
Level 12

I don't know @rahulkmofficial, I appreciate any help I can find, I don't want to mess with my vendor folders by doing something I might regret... I've never done this. However I created a file info with this:

<?php

phpinfo();

?>

And the version printed was 7.4.14

RahulKmOfficial's avatar

if you not made any changes in vendor it's safe to remove that but let it leave. do one thing make a new folder somewhere outside of your project & copy all files except node_modules & vendor.

there you can can do experiments your app will untouched , if everything fine you can make changes in your app. use git to avoid any accident.

however ^7.3 is ok, i am running production app which env is 7.4.X.

warpig's avatar
Level 12

Removing both of these folders bring up other issues like Laravel not finding some files and whatnot, unaware of the approach, could you be more specific like whats the intention of it? By removing and then running composer install && composer update, how would it impact the version used by Composer for my dependencies? Thanks.

EDIT: I mean I can understand this will reinstall composer and will update it, but how can I tell it to install a specific version? Inside composer.lock I see that there's a platform variable with a prefixed version of PHP, as you can understand it's been a while without success and I have a lot of questions.

RahulKmOfficial's avatar

everything seams correct so my first approach was there any package which has php 7.3 dependency. but i was wrong , problem is inside composer installation. i thought you have only php version on your computer so first thing if not needed remove all them except 7.4. then remove and reinstall composer make sure to remove composer configs from ($HOME/.composer/vendor/bin).

And please provide some info about your dev env.
like your installation type is native or comes with any package like lamp,xammp ,wamp etc. 

and answer of your question is you can but it's not good idea to make changes in composer-lock.json because with every update it changes.

jlrdw's avatar

Just upgrade to PHP 7.4. Composer would have nothing to do with that. Then just tell composer where your new PHP. exe is located.

warpig's avatar
Level 12

Hello @jlrdw can you say which path does Composer usually reaches for php? Im on a Mac. I found, by running which php a path that outputted this: /usr/local/bin/php this file has 7.4 version of PHP. Let's say I want to use this path, how would I go about redirecting Composer? Thanks :-)

jlrdw's avatar

For Mac I'm not sure, But in Windows I just run composer installer again, it ask for the PHP. exe. Is there a GUI installer For composer for a Mac.

Perhaps try searching stackoverflow.

warpig's avatar
Level 12

Theres a GUI for Windows on Composer?

warpig's avatar
Level 12

Maybe I should try and check which php version is being used by Apache?

warpig's avatar
Level 12

Does he go around installing Composer's version for dependencies? Yea, I could love a PHP course right now :-) I havent been able to figure out how to redirect Composer yet. Hope it doesn't take me too long.

Edit: I think im using Laravel 8, what's one way of figuring that out?

warpig's avatar
Level 12

By the way @jlrdw , the platform version in composer.lock , is the one used for all dependencies? Is that what you mean by installing composer again? I mean I've tried resetting that number and running composer install, could I change the settings for that file? I can also try this but don't know how convenient would be: https://php.watch/articles/composer-ignore-platform-req

jlrdw's avatar

I wasn't referring to laravel here, composer install is for installing the framework.

What I meant, is when I install a new php version, I also reinstall composer and point it to my php.exe file.

Laravel has nothing to do with a new composer install.

Are you saying you need several versions of php on your system?

Edit: Sorry if I am misunderstanding something.

warpig's avatar
Level 12

I want to use a package that requires 7.4 of PHP.

warpig's avatar
Level 12

Do you know where the .bash_aliases is located? I can see .bash_profile, according to an answer in StackOverflow, (produced by the URL you provided) I could make an alias for Composer and in that way resolve that issue of redirecting Composer, but I don't know where that is. Anyway what I found on .bash_profile is interesting:

alias composer733='/c/[xampp folder]/php733/php.exe /c/ProgramData/ComposerSetup/bin/composer.phar '. .bash_profile

But that path seems to be of a Windows OS machine. However it checks with what the answer is suggesting, there's an alias, and the version used there seems to be of a 7.3 PHP. I ran brew search phpand various versions came out:

==> Formulae
brew-php-switcher   php-cs-fixer        [email protected] ✔           phpmyadmin
php ✔               [email protected] ✔           phplint             phpstan
php-code-sniffer    [email protected] ✔           phpmd               phpunit

3 versions are checked, im guessing those are the ones installed on my Macbook?

warpig's avatar
Level 12

Damn! This is much much much harder than I thought. composer -vvv about 2>&1 | grep "PHP" says it's

Running 2.0.9 (2021-01-27 16:09:27) with PHP 7.4.14 on Darwin / 19.6.0
Composer - Dependency Manager for PHP

And phpinfo() outputs PHP Version 7.3.25

hamidali's avatar

Have you fixed the issue? I guess the problem is with the web server you are using

Please or to participate in this conversation.