Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Dancro's avatar

It shows that the route is not defined even if it is defined

I am trying to make a multilang website and ive watched a lot of tutorials but nothing works i tried the followings for routes:

Route::get('/lang/{lang}', [LanguageController::class, 'switchLang'])->name('lang.switch');

or

Route::get('/lang/{lang}', ['as' => 'lang.switch', LanguageController::class, 'switchLang']);

or

Route::get('lang/{lang}', ['as' => 'lang.switch', 'uses' => '\App\Http\Controllers\LanguageController@switchLang']);

and nothing worked i get the same error, the route is not defined somehow, and in the blade where im trying to use it, ive written:

"{{ route('lang.switch', ['lang' => 'it']) }}" in the href

i've put the question on stack too but still not an answer: https://stackoverflow.com/questions/71017971/why-does-my-language-switcher-not-translate-the-page?noredirect=1#comment125542707_71017971 what can i do ?

0 likes
5 replies
jaseofspades88's avatar

Please wrap your code examples in ``` (three back-ticks) as this is markdown. We might be able to help if we can read your snippet a little more clearly

jaseofspades88's avatar

What is the output in your terminal when you run the following command:

php artisan route:list

This command should give you a list of all the available routes and their names so you can see what is being loaded by Laravel.

1 like
Sinnbeck's avatar

Make sure that you havent cached your routes

php artisan route:clear
1 like
Dancro's avatar

@Sinnbeck that was it.. now it works to load the page and click on it but doesnt affect the content at all, its stays the same on it and on en even tho i used:

<h2 data-animation="animated slideInLeft">{{__('text.Produzione')}}</h2>
<p data-animation="animated slideInUp">{{__('text.Produzione-text')}}</p>

Please or to participate in this conversation.