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

movepixels's avatar

Php Version running error

Maybe I should give up using Laravel because everytime I do a composer {something} i end up wasting a week figuring out why something broke.

I simply ran this command:

composer require league/flysystem-aws-s3-v3

Now i get error:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.29. in /Users/admiral/www/admin/api/vendor/composer/platform_check.php on line 24

terminal php -v shows:

PHP 7.4.26 (cli) (built: Nov 28 2021 16:53:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.26, Copyright (c), by Zend Technologies

Any ideas? Mac OS Monterey using Brew with [email protected] (7.3.33) and [email protected] ( 7.4.26 ) available currently linked to 7.4

0 likes
14 replies
jlrdw's avatar

@movepixels when working with packages, always view all the composer.json files involved and check for proper dependencies prior to installing anything. And it does take a few minutes research.

I usually bring up a text editor and take note of any mismatches.

movepixels's avatar

@anilkumarthakur60 composer snip:

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

I never changed that so if it went from 7.3 to 7.4? This is why i hate these easy updates because ends up asking all you kind folks why I always end up breaking the site :)

movepixels's avatar

This is the composer file:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.4|^8.0",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.40",
        "laravel/tinker": "^2.5",
        "league/flysystem-aws-s3-v3": "^1.0",
        "league/flysystem-cached-adapter": "^1.1",
        "tymon/jwt-auth": "^1.0"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },
    "autoload": {
      "files": ["app/Helpers/functions.php"],
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "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"
        ]
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

I deleted the composer.lock, deleted vendors, composer install => no errors installing.

Same error saying i have lower php version, yet php -v shows 7.4.xxx

movepixels's avatar

just to see where laravel is looking i added in

echo phpinfo();

to the top of public/index.php file

PHP Version 7.3.29
Configuration File (php.ini) Path	/usr/local/etc/php/7.3
Loaded Configuration File	/usr/local/etc/php/7.3/php.ini
Scan this dir for additional .ini files	/usr/local/etc/php/7.3/conf.d

Inside /usr/local/etc/php/ are the various php version folders => [7.2, 7.3, 7.4, 8.0, 8.1]

Just don't know why it's selecting 7.3, where is that information set telling to use that version?

So why laravel is pulling this? how? where is this config defined? I set everything up via brew so this appears to be the default php that comes bundled in with the Mac?

Any ideas? Thanks all, sorry for the hassle.

Snapey's avatar

@movepixels if you run phpinfo from the browser then it's your webserver that is using the wrong version

it might be as simple as restarting your webserver after switching versions, but also you may need config changes depending on your choice of webserver

movepixels's avatar

@Snapey

I restarted the Mac, switched linked / unlinked the various php versions and tested with php -v after each change in the terminal and it shows correct what version i changed to. Laravel no matter what only find the 7.3

I can change to [email protected] and verifiy the -v, laravel still says sorry your running 7.3

Basic brew setup with nginX, php7.x, 8.x, mySQL, pretty basic stuff. I have other sites running on this dev machine and only need 7.3 so they are still running but this site in question needs 7.4 and still looking somehow for 7.3

movepixels's avatar

I just cant seem to find where its getting 7.3.xxx from.

terminal i can change the php versions link / unlink and check with -v and shows the version i linked.

But the versions are all inside brew as it would be expected. Yet laravel seems to be looking and finding php that comes installed on the mac default. I dont know how / where laravel decides to look and use the default php?

movepixels's avatar

Absolutely makes no sense. I deleted vendors, and changed the package.json file to ""php": "7.3",

run composer install

Now it tells me I'm using 7.4.26 and cant use 7.3,

Problem 1
    - Root composer.json requires php 7.3 but your php version (7.4.26) does not satisfy that requirement.

Change the package.json file back to original => "php": "^7.4|^8.0",

run composer install

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.4.0". You are running 7.3.33. in /Users/admiral/www/admin/api/vendor/composer/platform_check.php on line 24

terminal shows I am currently running 7.4.26

Any ideas?

movepixels's avatar

@Tray2 Using nginx

I came across this and this is where I left off / starting to try. https://kevdees.com/macos-11-big-sur-nginx-setup-multiple-php-versions/

Along the same lines as your link, so thanks for that.

One thing I noticed is my sites-available php block the fast-cgi is commented out:

location ~ \.php$ {

       #fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
       #fastcgi_index index.php;
       #fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
       #include fastcgi_params;

       try_files      $uri = 404;
       fastcgi_pass   127.0.0.1:9000;
       fastcgi_index  index.php;
       fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include        fastcgi_params;

   }

But I am going to try to alter the port and set the port for each version as detailed in the link.

Will post results

Wish me luck!

movepixels's avatar

Ok i set the port as described in the link based on the version i need, linked brew to that version, editied the port that version of php listens to and now its working

Thanks to all who helped. Who would like the solved best answer since you all helped :)

Please or to participate in this conversation.