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

michalis's avatar

why two php versions in composer.json?

Hey guys, in the composer.json file for a fresh laravel installation the php line is like so:

"php": "^7.3|^8.0"

im not sure why it is done like this, I use sail and it pulls in a php 8 docker image, but when I open in php storm, it syncs to composer.json but goes with php 7.3 and as a result I cant use php 8 related functions like converting into an arrow function

phpstorm support told me to just remove 7.3 from composer.json, but I assume there is a reason why its there right?

0 likes
5 replies
SilenceBringer's avatar
Level 55

@michalis it's php versions compatibility. It allows other team members who have php 7.3 on the machine still use you application. Or allows you to have php 7.3 on server, for example

Of course, you can't use php8 functions this way.

You are free to remove php 7 support from composer.json if all your team members use php8 and on the server you'll have php8

1 like
Snapey's avatar

composer does not choose the version to use, it's only saying what it needs

it's up to your local configuration regarding what php version actually runs

1 like
michalis's avatar

I understand that, I just wanted to point out that composer.json has more than one version as a dependency, which confuses php storm

and I wanted to know if it would be ok to remove one of the versions so that php storm could function as it should

martinbean's avatar

@michalis It’s just saying the project works with either PHP 7.3 (and above) or PHP 8.0 and above.

1 like
michalis's avatar

ok thank you, so there shouldn't be a problem in removing 7.3

Please or to participate in this conversation.