Method Illuminate\Translation\Translator::getFromJson does not exist

PhpLaravel

Php Problem Overview


After upgrading from laravel 5.8 to laravel 6.0, I found this error.

>Method Illuminate\Translation\Translator::getFromJson does not exist

Anyone know any work around for this?

It seems that problem is from using @lang for printing translation messages in my blade file

Php Solutions


Solution 1 - Php

Hy Prasanth

The Lang::get and Lang::getFromJson methods have been consolidated in laravel . Calls to the Lang::getFromJson method should be updated to call Lang::get.

You should run the php artisan view:clear Artisan command to avoid Blade errors related to the removal of Lang::transChoice, Lang::trans, and Lang::getFromJson.

Thank you.

Solution 2 - Php

Try php artisan view:clear

The issue is that your view files have been compiled in 5.8, so @lang has compiled to Lang::getFromJson which has now been removed.

Solution 3 - Php

If php artisan view:clear doesn't work on debian server, maybe permission is denied.

Try sudo rm storage/framework/views/*

Solution 4 - Php

Please use Lang::get('your name') in laravel 6

Solution 5 - Php

If php artisan view:clear doesn't work

in my case view of 404,500,and more in vendor folder is the problem

you can try deleting 'vendor' folder and run composer install again

Good luck,

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPrasanth M PView Question on Stackoverflow
Solution 1 - PhpskmView Answer on Stackoverflow
Solution 2 - Phpchris_codeView Answer on Stackoverflow
Solution 3 - Phpmodule-artView Answer on Stackoverflow
Solution 4 - PhpRameshView Answer on Stackoverflow
Solution 5 - PhpalbirrkarimView Answer on Stackoverflow