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

vincej's avatar
Level 15

Route List not the same as web.php

I have done a php artisan cache:clear, route:clear, clear-compiled. And still when I do a route:list it refuses to reflect the one specific route as written within web.php. Instead it will list a route that I had described much earlier.

earlier route: salesAndWorkOrder

current route: salesWorkOrder

even if I change the route back to the earlier version it still does not find it, and I get a

NotFoundHTTPException

Ok - so thinking it was PHPStorm, I did an invalidate caches restart, and Nope.

The spelling is the same, the capitalisation is the same.

the route is being called out of a view using a forloop like this:

<a  style="font-weight: bold; text-decoration-line: underline;color: darkblue" href="/salesWorkOrder/{{$orders[$i]->reference}}" target="_blank"> {{ $orders[$i]->reference}}</a>

What am I doing wrong ??

Many thanks !

0 likes
36 replies
Jaytee's avatar

Run php artisan route:cache and then php artisan route:clear.

Then, for as long as you're in development mode, don't cache routes or configuration files. Only in production. Caching the routes above, should fetch a fresh copy of routes, and then we'll just clear them out again.

Restarting your local server will also help

After running the route:clear command, double check that there is no file in the bootstrap/cache directory, named routes.php.

vincej's avatar
Level 15

Thanks for the reply. Followed your instructions, but it didn't work. I still have the rogue route, and the URL still does not find correct route in web.php

However, something did occur which was weird: when running php artisan route:cache I got this back:

Route cache cleared!

In Route.php line 917:
                                                                       
Unable to prepare route [api/user] for serialization. Uses Closure.

Any more ideas?

vincej's avatar
Level 15

Additionally, when I look into Barry's debug bar it tells me there is no route being called. Furthermore, there is no Auth status reported in the debug bar. However, the controller uses auth:admin middleware.

The debug bar reports Auth thus:

web
array:2 [ "name" => "Guest" "user" => array:1 [ "guest" => true ] ]
admin
array:2 [ "name" => "Guest" "user" => array:1 [ "guest" => true ] ]

Nakov's avatar

@vincej you mentioned this happening in the web.php file, but the error says api/user have you checked your api.php file as well for any overriding?

What if you add a completely new route, will it show when you do php artisan route:list?

Talinon's avatar

The default install of Laravel/Laravel has a route closure in routes/api.php. You can't cache closures, which explains why you get that error. The fact you get that error suggests that this is probably not a cache problem since it's unlikely you ever performed a cache.

Did you change anything within your App/Providers/RouteServiceProvider.php?

vincej's avatar
Level 15

Thanks for your replies..

@nakov I have no routes in the api.php file other than the Laravel default.

Very concerning is that if I add a wholly new route, it does not show up in the route:list.

@talinon no I have done nothing to App/Providers/RouteServiceProvider.php

Nakov's avatar

@vincej if route:clear does not work, try manually deleting the cached file if it exists:

bootstrap/cache/routes.php -> delete this.

Dalma's avatar

I once had a similar issue but I found that I had syntax error in my web.php file.

Nakov's avatar

@dalma but if you have a syntax error in the web.php I don't think that running php artisan route:list will show any results at all, right?

Talinon's avatar

Did you upgrade from 5.2 recently? Any chance you are editing old/obsolete route files within app/Http/Routes?

vincej's avatar
Level 15

api/user is showing up in the route:list.

Nakov's avatar

@vincej can you please share the content of your web.php file so we stop guessing what is going wrong? :)

vincej's avatar
Level 15

@nakov here it is - very big !


My Routes file has now been deleted. 

Nakov's avatar

@vincej so back to your initial question, you said that calling salesWorkOrder throws a not found exception.. based on your file I don't see a route endpoint with that name.. I see a method on a controller which is commented now, but no endpoint..

So in order for something like this:

<a  style="font-weight: bold; text-decoration-line: underline;color: darkblue" href="/salesWorkOrder/{{$orders[$i]->reference}}" target="_blank"> {{ $orders[$i]->reference}}</a>

to work, you will have to have a route like this:

Route::get('/salesWorkOrder/{id}', 'InventoryController@salesWorkOrder');
vincej's avatar
Level 15

Yes, of course.

However, I have deleted the route salesWorkOrder as well as the salesAndWorkOrder route and replaced it with a new route as per an earlier suggestion.

The new route does not show up on route:list and most concerning the very original route salesAndWorkOrder still does.

   | GET|HEAD  | salesAndWorkOrder/{id}                 | salesAndWorkOrder        | App\Http\Controllers\InventoryController@salesWorkOrder                           | web,auth:admin          

Additionally I did a project wide search for salesAndWorkOrder and search comes up blank.

Furthermore, I have just copied across the contents of a web.php file from a few days ago where there was no salesAndWorkOrder and I am still getting this rogue route in my route:list

it's a mystery.

Nakov's avatar

@vincej and have you tried this from what I've said above:

if route:clear does not work, try manually deleting the cached file if it exists:

bootstrap/cache/routes.php -> delete this.

Other than this just create a new project and copy everything over :D

Nakov's avatar

@vincej what I would do is remove ALL the routes from the file, and just leave that one only, and make sure that it appears when running php artisan route:list.. Other than this, I would really create a new project and move over things.

And btw, what do you use for development? XAMPP, WAMP, Homestead, Docker?

vincej's avatar
Level 15

Ok - I did as you suggested. I deleted ALL the routes leaving one only, and did a route list. Guess what ... they were still all there.

Creating a new project in PHPStorm is a real ball ache.

MANY THANKS ! Cheers from cold and snowy Canada.

Snapey's avatar

not sure how you can have no bootstrap cache folder?

Perhaps if you actually cache the routes and then clear the cache?

php artisan route:cache

php artisan route:clear
vincej's avatar
Level 15

@nakov I run everything straight off of Linux Mint which is a derivative of Ubuntu 16.

@snapey I just did again, as per your suggestion and as per the previous attempt it had no effect. The rogue route is still there, and there is no Bootstrap cache folder

Talinon's avatar

Another wild and crazy thought... Are you actually running the full artisan commands? Any possibility of using a bash alias, or an editor plugin, that is running artisan from another project directory?

Talinon's avatar

I also use Linux Mint, and I vaguely recall experiencing something like this once. It wasn't specifically route files, but any code change wasn't being recognized. I think it had something to do with changing the system date in the future and it bugged out the webserver. I think a restart of Apache solved the issue. It doesn't hurt to give it a try.

sudo service apache2 restart

vincej's avatar
Level 15

Thanks for that. Nope... no hope. Back to a fresh install.

siangboon's avatar

i would probably put the one route that i would like to test and comment out all others to test it out....

Jaytee's avatar

I've read a thread online. Updating their composer dependencies seemed to fix the issue.

See if that'll work for you. I vaguely remember having an issue like this in the past, but I ended up porting it over to a fresh installation to resolve it.

Jaytee's avatar

And also, if you could provide the full laravel version that you're on. That would be great.

connecteev's avatar

@vincej perhaps if you can put up your project (or bits thereof) online - github ideally, others can help debug or at least replicate the problem.

Next

Please or to participate in this conversation.