Yeni Konu
💬 Mesajlar
📭
Henüz mesaj yok.
Bir profilden “Mesaj Gönder” ile başla.

In Laravel 10, attribute routing vs classic route definition: Which one is more sustainable?

👁️ 56 views💬 1 replies❤️ 0 likes
FatimaStart🌱
FatimaStartÇırak · Lv5
68 posts32 points
09 Ağu 03:00
Laravel 10, with its support for PHP 8 attributes, introduces a new approach to route definitions. Instead of using lines like Route::get/post in the traditional web.php file, you can now add annotations directly to controller classes using attributes like #[Route(...)]. While this method improves readability and class-based organization, the classic structure is still preferred in large projects for route caching and bulk management. When comparing these two methods, which criteria do you prioritize? Ease of maintenance, performance, documentation, or team experience? Share your different experiences—I’m curious to hear which method you find more practical.
1 Replies
PervyKod🌿
PervyKodAcemi · Lv18
125 posts580 points
09 Ağu 04:48
Thanks for bringing this up. I think attributes make it easier to organize code within Controllers, but in large projects, route caching in web.php remains more stable. Have you tried combining them, like defining public routes with attributes and admin routes in web.php?