Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP 7.2 throws run "composer require symfony/dotenv", 7.1 does not

A Symfony 4.2 application built (& working) in PHP 7.1, when switched to 7.2 throws

Fatal error: Uncaught RuntimeException: Please run "composer require symfony/dotenv" to load the ".env" files configuring the application...

Further, composer update yields Nothing to install or update and then

Script cache:clear returned with error code 255 !! !! Fatal error: Uncaught RuntimeException: You need to add "symfony/framework-bundle" as a Composer dependency. in G:\Documents\workspace\mana\bin\console:14

After updating composer.json to require PHP 7.2, it now includes:

"require": {
    "php": "^7.2",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "beberlei/doctrineextensions": "^1.1",
    "easycorp/easyadmin-bundle": "^2.0",
    "knplabs/knp-snappy-bundle": "^1.6",
    "ob/highcharts-bundle": "^1.6",
    "sensio/framework-extra-bundle": "^5.1",
    "symfony/asset": "4.2.*",
    "symfony/console": "4.2.*",
    "symfony/dotenv": "4.2.*",
    "symfony/expression-language": "4.2.*",
    "symfony/flex": "^1.1",
    "symfony/form": "4.2.*",
    "symfony/framework-bundle": "4.2.*",
    "symfony/monolog-bundle": "^3.1",
    "symfony/orm-pack": "*",
    "symfony/process": "4.2.*",
    "symfony/security-bundle": "4.2.*",
    "symfony/serializer-pack": "*",
    "symfony/swiftmailer-bundle": "^3.1",
    "symfony/templating": "4.2.*",
    "symfony/test-pack": "^1.0",
    "symfony/translation": "4.2.*",
    "symfony/twig-bundle": "4.2.*",
    "symfony/validator": "4.2.*",
    "symfony/web-link": "4.2.*",
    "symfony/webpack-encore-bundle": "^1.0",
    "symfony/yaml": "4.2.*"
},

Edit: If, as suggested in the error message, composer update is run, the following occurs. As can be seen in composer.json above, this is nonsensical.

Fatal error: Uncaught RuntimeException: You need to add "symfony/framework-bundle" as a Composer dependency. in G:\Documents\workspace\mana\bin\console:14

Edit #2: This does not appear to be a Symfony or a PHP issue. I'm working in Windows and have a Hyper-V Ububtu 18 server running a clone of the app in Apache/2.4.29, PHP Version 7.2.19 without a problem. Makes it a whole lot harder to sort out. Place this Q on hold?

Edit #3: Restored a two month old Windows image and got the same effect. Returned to current image and learned that the errors described above start somewhere between PHP 7.10 & 7.16 on this box. Upgrading Symfony to 4.3 does not help. ARRRGGGHHH!

Final edit: Sorting this out is beyond my skill set. I'll end with the output of PHP 7.2.20. There is no dev.log created. Netbeans 11 does not seem to recognize xdebug. Here:

(1/1) FatalErrorException

Error: During class fetch: Uncaught ReflectionException: Class PHPUnit\Framework\TestCase not found in G:\Documents\workspace\mana\vendor\symfony\framework-bundle\Test\KernelTestCase.php:24 Stack trace:

0 G:\Documents\workspace\mana\vendor\symfony\debug\DebugClassLoader.php(159):

require('G:\Documents\wo...')

1 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass('Symfony\Bundle\...')

2 G:\Documents\workspace\mana\vendor\symfony\framework-bundle\Test\WebTestCase.php(22):

spl_autoload_call('Symfony\Bundle\...')

3 G:\Documents\workspace\mana\vendor\symfony\debug\DebugClassLoader.php(159):

require('G:\Documents\wo...')

4 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass('Symfony\Bundle\...')

5 G:\Documents\workspace\mana\vendor\liip\functional-test-bundle\src\Test\WebTestCase.php(41):

spl_autoload_call('Symfony\Bundle\...')

6 G:\Documents\workspace\mana\vendor\symfony\debug\DebugClassLoader.php(159):

require('G:\Documents\wo...')

7 [internal function]: Sy in KernelTestCase.php line 24

like image 789
geoB Avatar asked Dec 31 '22 19:12

geoB


1 Answers

I also encountered this issue, but in my case the issue is that composer had updated to 2.0.11 and that's what generated the error regarding that Please run "composer require symfony/dotenv" to load the ".env" files configuring the application. I went back to composer 2.0.8 and all was well again. I believe 2.0.9 also works.

like image 181
kcap Avatar answered Jan 05 '23 09:01

kcap