composer: PHP 7.3 breaks composer with continue/targeting error (solution: downgrade to 7.2)

PHP version not working:

/usr/bin/php7.3 -v
PHP 7.3.0RC4 (cli) (built: Nov  7 2018 10:06:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.0RC4, Copyright (c) 1999-2018, by Zend Technologies

PHP version working:

PHP 7.2.12-1+0~20181112102304.11+stretch~1.gbp55f215 (cli) (built: Nov 12 2018 10:23:04) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.12-1+0~20181112102304.11+stretch~1.gbp55f215, Copyright (c) 1999-2018, by Zend Technologies

My composer.json:

empty / not existing

Output of composer diagnose:

[some bullshit complaining about a wrong SPDX-license code which is clearly existing on https://spdx.org/licenses/]
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK

When I run this command:

kako@devserver:~/skripte$ composer require mpdf/mpdf -vvv

I get the following output:

Reading ./composer.json
Loading config file ./composer.json
Checked CA file /etc/ssl/certs/ca-certificates.crt: valid
Executing command (/home/kako/skripte): git branch --no-color --no-abbrev -v
Executing command (/home/kako/skripte): git describe --exact-match --tags
Executing command (/home/kako/skripte): git log --pretty="%H" -n1 HEAD
Reading /home/kako/.composer/composer.json
Loading config file /home/kako/.composer/composer.json
Running 1.2.2 (2016-11-03 17:43:15) with PHP 7.3.0RC4 on Linux / 4.9.0-8-amd64
Downloading https://packagist.org/packages.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/packages.json into cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2013.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2014.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2015.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2016.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2017.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-01.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-04.json from cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-07.json from cache
Downloading http://packagist.org/p/provider-2018-10%24aa9e2fdf4422be2ee3f3633edaf047f05e92c0ec96f760c5fa2f2257f89fa98e.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/p-provider-2018-10.json into cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/p-provider-archived.json from cache
Downloading http://packagist.org/p/provider-latest%2430d19a056d26ac01f571e70ec61607d697a76339914cc646bdfa8416f79f7f07.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/p-provider-latest.json into cache
Reading /home/kako/.cache/composer/repo/https---packagist.org/provider-mpdf$mpdf.json from cache
Using version ^6.1 for mpdf/mpdf
./composer.json has been updated
Reading ./composer.json
Loading config file ./composer.json
Executing command (/home/kako/skripte): git branch --no-color --no-abbrev -v
Executing command (/home/kako/skripte): git describe --exact-match --tags
Executing command (/home/kako/skripte): git log --pretty="%H" -n1 HEAD
Reading /home/kako/.composer/composer.json
Loading config file /home/kako/.composer/composer.json
Loading composer repositories with package information
Downloading https://packagist.org/packages.json
Writing /home/kako/.cache/composer/repo/https---packagist.org/packages.json into cache
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.

                                                                                           
  [ErrorException]                                                                         
  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?  
                                                                                           

Exception trace:
 () at /usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php:286
 Composer\Util\ErrorHandler::handle() at /usr/share/php/Composer/autoload.php:258
 require() at /usr/share/php/Composer/autoload.php:258
 {closure}() at n/a:n/a
 spl_autoload_call() at /usr/share/php/Composer/DependencyResolver/Solver.php:75
 Composer\DependencyResolver\Solver->__construct() at /usr/share/php/Composer/Installer.php:459
 Composer\Installer->doInstall() at /usr/share/php/Composer/Installer.php:216
 Composer\Installer->run() at /usr/share/php/Composer/Command/RequireCommand.php:175
 Composer\Command\RequireCommand->execute() at /usr/share/php/Symfony/Component/Console/Command/Command.php:259
 Symfony\Component\Console\Command\Command->run() at /usr/share/php/Symfony/Component/Console/Application.php:844
 Symfony\Component\Console\Application->doRunCommand() at /usr/share/php/Symfony/Component/Console/Application.php:192
 Symfony\Component\Console\Application->doRun() at /usr/share/php/Composer/Console/Application.php:231
 Composer\Console\Application->doRun() at /usr/share/php/Symfony/Component/Console/Application.php:123
 Symfony\Component\Console\Application->run() at /usr/share/php/Composer/Console/Application.php:104
 Composer\Console\Application->run() at /usr/bin/composer:44

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader]` [-a|--classmap-authoritative] [--] [<packages>]...

And I expected this to happen: composer installing mpdf šŸ˜‰

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (5 by maintainers)

Most upvoted comments

As a quick and dirty alternative, you can fix the error in that one file. Just replace ā€œcontinueā€ with ā€œbreakā€ (or maybe ā€œcontinue 2ā€).

/usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php at line 286

Using composer self-update worked for me!

For me Same error occured as:

[ErrorException] ā€œcontinueā€ targeting switch is equivalent to ā€œbreakā€. Did you mean to use " continue 2"?

and what i have done is downloaded the latest composer from the official site and now it is working fine so there is not any fault of PHP 7.3. And downgrading to PHP 7.2 is not the solution. it is giving error because of old version of composer and if you are troubling with the same issue try to upgrading the composer first and see if it works for you.

Which version of Composer do you use? This has been fixed in c8615358cb83d695473d350dcf7f82ef35e287e9 which was part in all releases starting with 1.6.0.

Thanks @voghDev used your suggestion. adding `

UPGRADE COMPOSER

RUN php -r ā€œcopy(ā€˜https://getcomposer.org/installer’, ā€˜composer-setup.php’);ā€ RUN php -r ā€œif (hash_file(ā€˜sha384’, ā€˜composer-setup.php’) === ā€˜48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5’) { echo ā€˜Installer verified’; } else { echo ā€˜Installer corrupt’; unlink(ā€˜composer-setup.php’); } echo PHP_EOL;ā€ RUN php composer-setup.php RUN php -r ā€œunlink(ā€˜composer-setup.php’);ā€

`

in the web dockerfile . just before composer is used solved this for me

Yeah… thanks linux packages šŸ˜• Please install from https://getcomposer.org to get the latest code. We can’t offer support for outdated versions sorry.

Thanks for the information. My case is not the same as the creator of the issue but I was getting the same error (the one pointed by @Haritsinh). Finally solved it upgrading my version of composer as he mentioned. I did it by following the download instructions in getcomposer.org. Thanks everyone for your help 😃

@voghDev This is not related to composer. One of your dependencies is raising a warning with PHP 7.3. You have to find out which one and upgrade it. I know that doctrine/orm used to have this problem, but it could also be anything else. Maybe take this to stackoverflow with a detailed description which command showed the error and what your composer.json & lock looks like.

As a quick and dirty alternative, you can fix the error in that one file. Just replace ā€œcontinueā€ with ā€œbreakā€ (or maybe ā€œcontinue 2ā€).

/usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php at line 286

It works to me. Thanks!

FYI: Debian 9 is still installing composer 1.2.2 via .deb, so if you get here from Google because you are using PHP 7.2 o PHP 7.3 from debsury, you need upgrade composer binary manually to get composer 1.9 or upper and get rid the fatal error. You are welcome šŸ˜‰

As a quick and dirty alternative, you can fix the error in that one file. Just replace ā€œcontinueā€ with ā€œbreakā€ (or maybe ā€œcontinue 2ā€).

/usr/share/php/Composer/DependencyResolver/RuleSetGenerator.php at line 286

Thanks… worked for me…

Easyest way to Update Composer and working without install crash is

$ update-alternatives --set php /usr/bin/php5 $ composer self-update $ update-alternatives --set php /usr/bin/php7.3

Work for me in Debian and Ubuntu

You execute the command with the old version (as seen in your second screenshot). Your new installation is stored locally as /var/www/omofomo/com/composer.phar. You probably want to remove the composer installation installed via your package manager (apt or yum) and then store the manual installation in a folder that is accessible in your PATH environment variable. If you need help, this issue tracker is unfortunately not the right place for this, instead consider opening a question in an appropriate forum, e.g. on askubuntu.

If this is fixed and the website is the best way to get the latest composer…please explain this! Screenshot_2019-04-17_06-59-12 Screenshot_2019-04-17_07-11-29

Composer version 1.2.2 2016-11-03 17:43:15

Sorry, my bad. self-upgrading seems not be part of this version(?), coming from a debain package. Did’t expect it being that old…