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

GuntarV's avatar
Level 40

Should I use resource route if I only use ~3 resourceful methods in the controller?

Is it advisable to use Route::resource if I use only create, update, destroy methods in the controller? In my application I got quite a few helper lists / tables, where records are often created / updated / deleted through JavaScript on some random page. In those cases, I don't use the index, edit, show methods.

It does make the web.php route file shorter when using Route::resource. That's been the main reason I been doing that.

From what I understand, when I run php artisan optimize command, routes will be added into one long array, so it is quicker during request endpoint lookup.

The downside could be that the route's array may contain endpoints which are never used.

In my current project I have 350 - 400 endpoints.

Should I be concerned about the un-used endpoints in the route array, or am I over thinking it 🤔

0 likes
5 replies
GuntarV's avatar
Level 40

@nakov & @martinbean thank you for suggestions. Will definitely be using the only, except or api approaches.

I am not sure if I can have the Route::apiResource inside web.php or would it need to be inside api.php routes file?

martinbean's avatar
Level 80

@guntarv It’s just a method on the router. You can use it in any route files but yes, it’s intention is to be used for API routes defined in an api.php file.

Please or to participate in this conversation.