1

I tried creating new laravel project using composer but am getting the above error. Any help?

This is the command I used: "composer create-project --prefer-dist laravel/laravel project-name"

Some Output errors: Class Symfony\Component\Translation\Tests\DependencyInjection\TranslatorPassTest located in ./vendor/symfony/translation/TranslatorPassTest.php does not comply with psr-4 autoloading standard. Skipping.

Class Symfony\Component\Translation\Loader\ArrayLoader located in ./vendor/symfony/translation/ArrayLoader.php does not comply with psr-4 autoloading standard. Skipping.

Class Symfony\Component\Translation\Tests\Provider\NullProviderFactoryTest located in ./vendor/symfony/translation/Provider/NullProviderFactoryTest.php does not comply with psr-4 autoloading standard. Skipping.

The Ngere
  • 61
  • 9
  • 1
    What have you already done, tried? What commands have you used to create new project? – Adrian Kokot Sep 28 '21 at 09:24
  • I have tried this command "composer create-project --prefer-dist laravel/laravel project-name". Thanks. – The Ngere Sep 28 '21 at 09:27
  • Check the entire output and see if there were any errors installing any of the dependencies – apokryfos Sep 28 '21 at 09:29
  • See https://github.com/symfony/symfony/issues/43212 - this is a pretty new, but already known bug – Nico Haase Sep 28 '21 at 09:53
  • I can see I am not alone. Basically initial version (i.e "symfony/translation": "v5.3.7") would work for now. – The Ngere Sep 28 '21 at 10:01
  • Does this answer your question? [Creating new laravel project via composer fails with error class ArrayLoader not found](https://stackoverflow.com/questions/69359382/creating-new-laravel-project-via-composer-fails-with-error-class-arrayloader-not) – yivi Sep 28 '21 at 11:55
  • Kindly check the time the question was posted. I did my research well before asking. – The Ngere Sep 28 '21 at 16:13

4 Answers4

2

Until the namespace change is accounted for you can temporarily set

"symfony/translation": "v5.3.7"

Update it with composer update and it should work again.

2

The package has been updated to:

"symfony/translation": "v5.3.9"

and it is working well.

https://github.com/symfony/translation/releases/tag/v5.3.9

The Ngere
  • 61
  • 9
0

I have reverted my composer.lock and then just composer install. It seams that the translator new update is not properly set. For new installations the solution should be what the user3672987 gave as temp solution.

Deák Zsolt
  • 32
  • 1
  • 4
-1

Temporary solution :

You can quick fix it by adding temporarily this line to your composer.json

"symfony/translation": "v5.3.7",


Initial answer :

Same for me, got this error when I'm trying to install a new project or using composer install or composer update on any project :

> @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}(Object(Carbon\Laravel\ServiceProvider))

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

Edit :

Apparently, the package symfony/translation had a minor release that changed the namespace of ArrayLoader :

https://github.com/symfony/translation/releases/tag/v5.3.8

https://github.com/briannesbitt/Carbon/issues/2466

Jeremy B.
  • 32
  • 4