Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

php - Creating new laravel project via composer fails with error class ArrayLoader not found

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 'SymfonyComponentTranslationLoaderArrayLoader' not found

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

      +13 vendor frames
  14  [internal]:0
      IlluminateFoundationApplication::IlluminateFoundation{closure}()

      +5 vendor frames
  20  artisan:37
      IlluminateFoundationConsoleKernel::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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There seems to be a bug or incompatibility introduced in Symfony components on version 4.3.8.

Just add this to your composer.json:

 "conflict": {
        "symfony/symfony": "*",
        "symfony/translation": "v5.3.8",
        "symfony/messenger": "v5.3.8",
        "symfony/mailer": "v5.3.8",
        "symfony/notifier": "v5.3.8"
    },

Run composer update and the old versions will be installed. When 5.3.9 is released, the new ones will be installed automatically without having to change anything.

The core team is aware of this issue, and a fix will be surely released shortly.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...