The Ngere
The Ngere

Reputation: 61

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

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.

Upvotes: 1

Views: 1694

Answers (4)

The Ngere
The Ngere

Reputation: 61

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

Upvotes: 2

jippeheijnen
jippeheijnen

Reputation: 27

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.

Upvotes: 2

Deák Zsolt
Deák Zsolt

Reputation: 32

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.

Upvotes: 0

Jeremy B.
Jeremy B.

Reputation: 32

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

Upvotes: -1

Related Questions