Avoid bloating routes file with partial namespaces
Partial namespaces in routes.

Avoid bloating routes file with partial namespaces

In the latest version, Laravel has removed automatic namespace prefixing for the controllers. Now you can use class constant to add controllers in routes file.

No alt text provided for this image

Very useful for navigating the code, and it can save you some time.

But this comes with a little problem, the route file can become bloated with the namespaces of the controllers.

No alt text provided for this image

This has very neat solution, which is partial name-spacing. You can add partial namespace of the controller and append afterwards in the specific route.

No alt text provided for this image


Muhammad Farhan

Senior Full-stack Engineer | PHP/Laravel/Flutter | Team Leader

4 年

Great feature. They just have commented conteroller path in RouterServiceProvidor

要查看或添加评论,请登录

Taukeer Liaqat的更多文章

社区洞察

其他会员也浏览了