laravel-translation icon indicating copy to clipboard operation
laravel-translation copied to clipboard

Seems like this package is not compatible with PHP 8

Open rajinder-akratech opened this issue 3 years ago • 3 comments

I was using this package with Laravel 8 + PHP 7 and it was working fine but as I updated my PHP version to PHP 8 then it starts throwing an error

JoeDixon\Translation\Drivers\Translation::JoeDixon\Translation\Drivers\{closure}(): Argument #2 ($key) must be passed by reference, value given

and then I downgrade my PHP back to PHP 7.4 then it again starts working.

rajinder-akratech avatar Aug 17 '21 10:08 rajinder-akratech

This package is abandoned, I recommend you to fork it and make the needed changes to support your PHP version, pointing the composer dependency to your fork.

eduPHP avatar Aug 30 '21 13:08 eduPHP

thanks for the reply. I will fix it as per your suggestion.

rajinder-akratech avatar Dec 22 '21 14:12 rajinder-akratech

I have a quick solution for handle the abandoned package problem instead of making a fork. This solution is with composer 2 version.

In composer.json to add:

    "psr-4": {
      "JoeDixon\\" : "app/Overrides/JoeDixon/"
    },
    "exclude-from-classmap": [
      "vendor/joedixon/laravel-translation/src/Drivers/Translation.php"
    ]

Once made this. It's necessary to add all content of vendor/joedixon/laravel-translation/src/Drivers/Translation.php to a new file on app/Overrides/JoeDixon/Translation/Drivers/Translation.php.

And finally in line 65 to change:

array_walk($translations, function (&$value, &$key) use ($type, $group, $language, $languageTranslations) {

To this one

array_walk($translations, function (&$value, $key) use ($type, $group, $language, $languageTranslations) {

And it will work.

I hope this can help you guys. 😀

gboquizosanchez avatar Feb 23 '22 22:02 gboquizosanchez

This is now solved in v2.

joedixon avatar Sep 20 '22 20:09 joedixon

JoeDixon\Translation\Drivers\Translation::JoeDixon\Translation\Drivers{closure}(): Argument #2 ($key) must be passed by reference, value given i have the same problem how solve it ?

ali635 avatar Mar 03 '23 08:03 ali635