0

When I create a new composer project for laravel

composer create-project laravel/laravel laravel

I get the following error

> @php artisan package:discover --ansi

   Error

  Class 'Symfony\Component\Translation\Loader\ArrayLoader' not found

  at vendor/nesbot/carbon/src/Carbon/Translator.php:80
     76▕     public function __construct($locale, Translation\Formatter\MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
     77▕     {
     78▕         $this->initializing = true;
     79▕         $this->directories = [__DIR__.'/Lang'];
  ➜  80▕         $this->addLoader('array', new Translation\Loader\ArrayLoader());
     81▕         parent::__construct($locale, $formatter, $cacheDir, $debug);
     82▕         $this->initializing = false;
     83▕     }
     84▕

      +13 vendor frames
  14  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()

      +5 vendor frames
  20  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

I run it inside PHP 7.4.24 docker container (macOS) with the latest stable composer (2.1.8).

Full log https://pastebin.pl/view/bb4ae413

yivi
  • 42,438
  • 18
  • 116
  • 138
chingis
  • 1,514
  • 2
  • 19
  • 38
  • Does this answer your question? [Corrupted composer.json file in Laravel 8](https://stackoverflow.com/questions/65273978/corrupted-composer-json-file-in-laravel-8) – Collin Sep 28 '21 at 09:48
  • 1
    That's a bug that has been fixed within the last hours. Can you try to run your command again? – Nico Haase Sep 28 '21 at 12:04

2 Answers2

0

Seems many people have the same issue

Downgrade temporarilyy and manually to symfony/translate 5.3.7 or lower

yivi
  • 42,438
  • 18
  • 116
  • 138
Edwin Krause
  • 1,766
  • 1
  • 16
  • 33
-2

If you have symphony in composer.json file, downgrading the version would work. If not just add "Symfony/translation": "4.3.8"

"require": {
     ...
     "symfony/translation": "4.3.8",
    }

and then composer update

The version may be different so keep that in mind.

AnkitS
  • 90
  • 1
  • 6