Home > Net >  Symfony 5.4.9 Composer detected issues in your platform:
Symfony 5.4.9 Composer detected issues in your platform:

Time:06-10

I am totally new to Symfony. After I installed Symfony on my local ddev machine, I get this error

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.4.29. in /var/www/html/symfony/vendor/composer/platform_check.php on line 24

I tried to composer install --ignore-platform-reqs as well, and soon as I run it, I get this error message

Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /var/www/html/symfony/vendor/psr/log/src/LoggerInterface.php on line 30

My php version is

❯ php -v
PHP 8.1.6 (cli) (built: May 12 2022 23:44:22) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies

Compose.json

    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/flex": "^1.17|^2",
        "symfony/framework-bundle": "*",
        "symfony/runtime": "*",
        "symfony/yaml": "*"
    },
    "require-dev": {
    },
    "config": {

Thanks for help

CodePudding user response:

Run this command:

symfony local:php:list

You will get some output listing the various versions of php you have installed on your computer and the one being used by the symfony binary will be highlighted. There will also be instructions on how to control the version used by the binary:

To control the version used in a directory, create a .php-version file that contains the version number (e.g. 7.2 or 7.2.15).

CodePudding user response:

Edit these 2 things in your composer.json to solve your problem :

 "require": {
        "php": ">=8.1",
}

And

"config": {
        "platform": {
            "php": "8.1.6"
        },
    },
  • Related