Route not defined in Laravel 5.6 - php

I have defined a route in web.php
Route::get('/dashboard/create-sub-project/{id}', 'SubProjectController#create')->name('sub-project.create')->middleware('auth');
and adding it a view.php
<a href='{{ route('sub-project.create', $project->id) }}'>Create new project</a>
but it keeps on throwing an error
Route [sub-project.create] not defined. (View:
view.blade.php)
Other routes I have defined works fine.

php artisan route:list
The problem was, I have added two routes on the same name with the different intention that caused the issue. Removed duplicate fixed the issue in Web.php

In Your command prompt run
php artisan route:list
the Clear route cache by running
php artisan route:clear
then you will be good to go.

Related

Laravel : command php artisan route:list generates an error : AuthController not found

I am working in a laravel project running version 5.6.39. When I try to run a command php artisan route:list, it generates an error saying "ReflectionException : Class App\Http\Controllers\Auth\AuthController does not exist".
routes\web.php looks like...
How can I resolve this issue? Please help.
Thank You.
The reason behind this issue is when you run php artisan route:list laravel reads all routes from routes folder and executes every controller that exists in them and if laravel couldn't find the controller or there is an error in them laravel throws an exception
so with that in mind it means you either removed App\Http\Controllers\Auth\AuthController or you moved it to another folder but didn't update the AuthController namespace and also the namespace in web.php so in your case you need to fix namespace in web.php and also in controller until they match

Laravel localization not working in all routes

I Blog in Laravel v5.6
when translate new route it doesn't work for me
but old route like login and register and landing pages it working as well when i going in new route it's not
Switch Lang page
Route::get('locale/{locale}', function ($locale) {
Session::put('locale', $locale);
return redirect()->back();
// this link will add session of language when they click to change langauge
})->name('locale');
Route::get('/{username}', 'ProfileAccountController#index')->name('profile')->middleware('admin.user');
when i going to this route it's not working and navbar and footer it's back to key, remove all code in this page and test the lang it's not work too.
I use all of this command and nothing
php artisan config:cache
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan clear-compiled
Thank you.
My suggestions:
Use middle-wear for changing languages and use https://github.com/spatie/laravel-translatable like this for more comfortable usage.
Also check this Change language in Laravel 5 might help you.
Had similar issues with Route closures. Try moving you're session setters/getters to a Controller and not within a Route closure.
https://laravel.com/docs/5.7/session#using-the-session
This will probably solve your issues.

Laravel 5.2 Only one specific route not found, but it does exist

No matter what I try, the route /authenticate/{code} returns a NotFoundHttpException.
My route in routes.php:
Route::get('/authenticate/{code}', ['as' => 'authenticate', 'uses' => 'FrontendController#getAuthenticate']);
When I am calling the route:
URL::route('authenticate', $code)
On my local machine it runs it just fine, but on my production server, it takes me to a NotFoundHttpException page.
It does site inside of the web middleware group.
I have tried (with no success):
resetting the github repo on the server (fresh install)
composer update
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear
composer dump-autoload
changing the route from authenticate to authenticate-email
What could it be? Every other route on the site works, it is just this one that doesnt.
The only thing I can think to advise is switching from using the URL Facade to using the built in helper function $url = route('authenticate', ['code' => $code]); I only say this because I can't seem to find in the docs how you hint at URI parameters when using URL::route() :)
I also ran into this issue. I deleted the route, then copy another working route and changed the route name and parameters with the one. And It Worked
I don't know if you solved this but I just had exactly the same problem, nothing I did would make the route work. It was a really simple route: Route::get('/search', ['middleware' => 'shop_session','uses' => 'Cinder\StoreController#viewProducts']);
Did all the things you did. In the end I moved the route to the top of my routes file, ran php artisan route:cache and it worked.
Not a great answer and I've got no idea why it worked but it did. Maybe worth a try?

php artisan make:controller error class Rout not found

php artisan make:controller was working but now produces this error?
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Rout' not found
Seems like you have a typo in your routes file, located at app/Http/routes.php.
You have Rout there instead of Route.
You are using Rout instead of Route
It must be a spelling mistake please check

Laravel 4 Routes Not Working

I did look at the other Laravel Route questions, but nothing seems to work for me.
I am trying Laravel 4. I ran the command:
php artisan controller:make PhotoController
to create my controller. Then I added a route in my routes.php file as such:
Route::resource('photo', 'PhotoController');
When I go to localhost/photo, I see 404 Not Found.
Any ideas? I can see the root and /index.php, they both say "Hello World", so I know something is working.
You might need to run
composer dumpautoload
from the command line, so laravel knows the controller is there.
you can also try this:
php artisan dump-autoload

Categories