'Type Error in Laravel 8 app when package barryvdh/laravel-translation-manager is installed

For last 3-4 weeks I receive this error in my Laravel 8 app, which breaks down my app. After uninstalling the package the problem disappears.

Please advice.

When using the Laravel app:

TypeError
Argument 2 passed to Symfony\Component\Translation\Translator::addResource() must be an instance of Symfony\Component\Translation\mixed, array given, called in D:\www\MyBooks\vendor\nesbot\carbon\src\Carbon\AbstractTranslator.php on line 165

when updating the app and dependencies:

TypeError

  Argument 2 passed to Symfony\Component\Translation\Translator::addResource() must be an instance of Symfony\Component\Translation\mixed, array given, called in D:\www\MyBooks\vendor\nesbot\carbon\src\Carbon\AbstractTranslator.php on line 165

  at D:\www\MyBooks\vendor\symfony\translation\Translator.php:109
    105|      * @param mixed  $resource The resource name
    106|      *
    107|      * @throws InvalidArgumentException If the locale contains invalid characters
    108|      */
  > 109|     public function addResource(string $format, mixed $resource, string $locale, string $domain = null)
    110|     {
    111|         if (null === $domain) {
    112|             $domain = 'messages';
    113|         }

  1   D:\www\MyBooks\vendor\nesbot\carbon\src\Carbon\AbstractTranslator.php:165
      Symfony\Component\Translation\Translator::addResource("array", "en")

  2   D:\www\MyBooks\vendor\nesbot\carbon\src\Carbon\AbstractTranslator.php:256
      Carbon\AbstractTranslator::resetMessages("en")


Solution 1:[1]

I had a similar problem when I tried to use my laravel project today. And I noted that the problem is related to the new version of Symfony "6.x," that only supports php:8.x only. And i downgraded the symfony package with all its dependencies using the following command.

$ composer require symfony/symfony:5.4.x --ignore-platform-reqs

I hope should works but its worked for me.

Solution 2:[2]

composer require symfony/symfony:5.4.x -w --ignore-platform-reqs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Mohammad Fanni