-1

I have this error when I run the composer install command:

laravel/framework[v9.0.0-beta.1, ..., 9.x-dev] require php ^8.0.2 -> your php version (7.4.33) does not satisfy that requirement.

I am mac user. On the termianl I run brew install php and its saying:

==> Downloading https://formulae.brew.sh/api/cask.json ######################################################################## 100.0% Warning: php 8.2.3 is already installed and up-to-date.

and then I run brew link php and its saying:

Warning: Already linked: /opt/homebrew/Cellar/php/8.2.3 To relink, run: brew unlink php && brew link php

my composer file:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "php": "^7.4||^8.0",
        "ext-bcmath": "*",
        "doctrine/dbal": "^3.5",        
        "google/apiclient": "^2.13",
        "googleads/google-ads-php": "^17.1",
        "guzzlehttp/guzzle": "^7.2",
        "jenssegers/mongodb": "^3.9",
        "laravel/framework": "^9.0",
        "laravel/sanctum": "^2.14",
        "laravel/socialite": "^5.5",
        "laravel/tinker": "^2.7",
        "php-open-source-saver/jwt-auth": "^2.0",
        "react/http": "^1.8",
        "shopify/shopify-api": "^4.1"
    },
    "require-dev": {
        "fakerphp/faker": "^1.9.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^6.1",
        "phpunit/phpunit": "^9.5.10",
        "spatie/laravel-ignition": "^1.0"
    },
    "autoload": {
        "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-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ],
        "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
}
Shibbir
  • 1,963
  • 2
  • 25
  • 48
  • 1
    Try `php -v` on the command-line, it's most likely still pointing to php 7.4 – aynber Feb 20 '23 at 17:52
  • @aynber yes its showing `PHP 7.4.33 (cli) (built: Feb 20 2023 04:52:32) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies` – Shibbir Feb 20 '23 at 17:57
  • how can I change the version? – Shibbir Feb 20 '23 at 17:58
  • See https://stackoverflow.com/questions/34909101/how-can-i-easily-switch-between-php-versions-on-mac-osx for how to change the PHP version – aynber Feb 20 '23 at 17:59
  • Yes I tried but same issue – Shibbir Feb 20 '23 at 18:00
  • Ah this first answer https://stackoverflow.com/questions/59142504/switch-of-php-versions-not-working-on-mac helped me :) – Shibbir Feb 20 '23 at 18:07

1 Answers1

0

I have had similar issues and this has fixed it for me. So i go into the directory where the application lives in terminal and run the following:

 brew unlink php@7.4
 export PATH="/usr/local/opt/php@8.1/bin:$PATH"
 brew link --force php@8.1

obviously replace the php versions with what you have

Yeak
  • 2,470
  • 9
  • 45
  • 71