laravel-translation
laravel-translation copied to clipboard
Seems like this package is not compatible with PHP 8
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.
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.
thanks for the reply. I will fix it as per your suggestion.
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. 😀
This is now solved in v2.
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 ?