skip to Main Content

After upgrade to php8 I have a problem with php-cs-fixer which I installed globally via composer. Right now I can not use php-cs-fixer because every time I get:

PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.4.*.
To ignore this requirement please set `PHP_CS_FIXER_IGNORE_ENV`.

For php upgrade and usage different version of php I use https://github.com/shivammathur/homebrew-php

For previous version of php (7.4) everything works fine.

3

Answers


  1. Chosen as BEST ANSWER

    The first version of php-cs-fixer to support PHP 8 was Version 2.18 released on 18th Jan 2021.


  2. In the file: ./vendor/bin/php-cs-fixer

    Remove the code below (starting at line 26):

    elseif (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50600 || PHP_VERSION_ID >= 70500) {
        fwrite(STDERR, "PHP needs to be a minimum version of PHP 5.6.0 and maximum version of PHP 7.4.*.n");
    
        if (getenv('PHP_CS_FIXER_IGNORE_ENV')) {
            fwrite(STDERR, "Ignoring environment requirements because `PHP_CS_FIXER_IGNORE_ENV` is set. Execution may be unstable.n");
        } else {
            exit(1);
        }
    }
    
    

    It’s a quick fix, but it will get you back up and running.

    Login or Signup to reply.
  3. https://cs.symfony.com/doc/usage.html#environment-options

    PHP_CS_FIXER_IGNORE_ENV=1 php php-cs-fixer.phar fix /path/to/dir

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search