5 Things you should NOT do in Laravel

Cerwyn Cahyono
4 min readMay 22, 2021
Photo by Jan Antonin Kolar on Unsplash

Laravel is one of the most popular PHP frameworks to be used today. Using Laravel, everything is working seamlessly. Because most of the features that we may need for building the app are already provided by Laravel.

However, be aware of all of these features. Because everything is working great, sometimes we don’t even think about the performance that our app may have. We may not be using the OOP properly or maybe we select the wrong technique when building the app. So here, based on my experience, there are several things that we should not do in our Laravel apps. Most of my points there are not only related to Laravel, but it could be related to the general idea of how we work as web developers.

Content Overview

  • One Controller for Everything
  • Procedural Code
  • Local for Everything
  • Nested If-Else
  • No Log, No DB Transaction

#1 One Controller for Everything

I’ve seen some developers treat the Laravel controllers to do everything. So we’ll have a very big fat controller with thousands of codes inside. Well, it might not be a good idea, because controllers should only handle one specific thing. For example, if we want to have a controller that handles…

--

--

Cerwyn Cahyono

PHP/Backend Engineer at Undercurrent Capital Pte Ltd — Data Science Enthusiast