0

I have a website made with the Yii2 Framework on a Debian 11 server.

When I do composer update on my server it returns the following error in my web:

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">=8.0.0".

I do not understand the error since my server is version 8.0.10

root@xxxx:/var/www/html/myweb# php -v
PHP 8.0.10 (cli) (built: Aug 25 2021 17:05:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies

I have tried with the command: composer install --ignore-platform-reqs and it works. However, I would like to be able to correct the error and that composer update will work as well.

How do I fix the composer error for the php version?

My composer.json:

{
    "name": "yiisoft/yii2-app-basic",
    "description": "Yii 2 Basic Project Template",
    "keywords": ["yii2", "framework", "basic", "project template"],
    "homepage": "http://www.yiiframework.com/",
    "type": "project",
    "license": "BSD-3-Clause",
    "support": {
        "issues": "https://github.com/yiisoft/yii2/issues?state=open",
        "forum": "http://www.yiiframework.com/forum/",
        "wiki": "http://www.yiiframework.com/wiki/",
        "irc": "irc://irc.freenode.net/yii",
        "source": "https://github.com/yiisoft/yii2"
    },
    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": ">=2.0.5",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "kartik-v/yii2-widget-switchinput": "*",
        "kartik-v/yii2-widget-datepicker": "@dev",
        "kartik-v/yii2-widget-datetimepicker": "1.4.2",
        "kartik-v/yii2-date-range": "1.6.7",
        "kartik-v/yii2-widget-activeform": "@dev",
        "kartik-v/yii2-widget-depdrop": "@dev",
        "kartik-v/yii2-widget-select2": "@dev",
        "kartik-v/yii2-grid": "@dev",
        "kartik-v/yii2-widget-fileinput": "@dev",
        "kartik-v/yii2-mpdf": "@stable",
        "kartik-v/yii2-popover-x": "*",
        "bower-asset/jquery": "@stable",
        "bower-asset/jquery.inputmask": "@stable",
        "bower-asset/punycode": "@stable",
        "kartik-v/yii2-export": "*",
        "opensooq/yii2-firebase-notifications": "dev-master",
        "yiisoft/yii2-imagine": "^2.1",
        "bupy7/yii2-widget-cropbox": "*",
        "kartik-v/yii2-editable": "*",
        "miloschuman/yii2-highcharts-widget": "^6.0",
        "newerton/yii2-fancybox": "dev-master",
        "nterms/yii2-pagesize-widget": "*",
        "yiisoft/yii2-jui": "^2.0",
        "kartik-v/yii2-widget-alert": "*",
        "kartik-v/yii2-sortable": "*",
        "wbraganca/yii2-dynamicform": "*",
        "kartik-v/yii2-sortable-input": "dev-master",
        "phpoffice/phpexcel": "*",
        "yii2tech/html2pdf": "^1.0",
        "boundstate/yii2-htmlconverter": "dev-master",
        "kartik-v/yii2-widget-sidenav": "*",
        "bower-asset/bootstrap": "^3.3",
        "npm-asset/jquery": "^2.2",
        "phpoffice/phpspreadsheet": "1.20.0"
    },
    "require-dev": {
        "yiisoft/yii2-codeception": "*",
        "yiisoft/yii2-debug": "*",
        "yiisoft/yii2-gii": "*",
        "yiisoft/yii2-faker": "*"
    },
    "config": {
        "process-timeout": 1800,
        "github-oauth": {

        }
    },
    "repositories": [
    {
        "type": "composer",
        "url": "https://asset-packagist.org"
    }
    ],
    "scripts": {
        "post-create-project-cmd": [
            "yii\\composer\\Installer::postCreateProject"
        ]
    },
    "extra": {
        "yii\\composer\\Installer::postCreateProject": {
            "setPermission": [
                {
                    "runtime": "0777",
                    "web/assets": "0777",
                    "yii": "0755"
                }
            ],
            "generateCookieValidationKey": [
                "config/web.php"
            ]
        },
        "asset-installer-paths": {
            "npm-asset-library": "vendor/npm",
            "bower-asset-library": "vendor/bower"
        }
    }
}

1 Answers1

0

Seems your composer running from the different php version.

You can check your composer php version by command composer -vvv about

enter image description here

Try to run composer from different php, like: /path/to/bin/php /path/to/composer update.

If this works, you can set alias for this command.

Denis Ostrovsky
  • 519
  • 1
  • 6
  • 16
  • Please share more details. How does this check resolve the problem? – Nico Haase Dec 01 '21 at 06:04
  • If php version thats running composer is under 8.0, you can get error like your. So you need to run your composer from other php version, like `/path/to/bin/php /path/to/composer update`. If it is right, you can set alias for this command – Denis Ostrovsky Dec 01 '21 at 06:12
  • Please add all clarification to your answer by editing it. Also, with the given additional information, it would be better to flag this question as a duplicate of https://stackoverflow.com/questions/32750250/tell-composer-to-use-different-php-version if you think that these hints resolve the problem – Nico Haase Dec 01 '21 at 06:21
  • 1
    composer -vvv returns me: Running 2.1.6 (2021-08-19 17:11:08) with PHP 8.0.10 however the error persists: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". – Jorge Palacios Zaratiegui Jan 23 '22 at 14:31