Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP and Composer

Running php composer.phar with the latest version gives me:

PHP Fatal error:  Cannot redeclare class Symfony\Component\Console\Helper\Helper in phar:/composer.phar/vendor/symfony/console/Symfony/Component/Console/Helper/Helper.php on line 19

What's up? Works fine locally, but on a Linux server.

This happens as soon as I try to run any commands or just the file directly. I can't self-update or anything. I've tried redownloading.

like image 996
Tower Avatar asked Feb 18 '23 20:02

Tower


1 Answers

Most likely you have apc.enable_cli set to 1, you can check with php -i | grep apc.

Another way to check everything is fine to run composer is running the installer in check-only mode:

curl -s https://getcomposer.org/installer | php -- --check

APC completely breaks down with PHARs (at least in CLI mode), and it does not provide any caching anyway in CLI since every process is independent, so disabling it makes sense, the flag is just there for debugging purposes AFAIK.

like image 91
Seldaek Avatar answered Feb 27 '23 12:02

Seldaek