10 Techniques for Cleaner Code
We've all written code that misses the mark. Sure, it works, but, still, you're left with the feeling that you've missed something. The difficult part, unfortunately, is recognizing what that "something" is.
In this series, we'll review ten techniques, one per episode, to improve the clarity of your PHP code.
Series episodes
Refactoring Insurance
13m 4sUse tests as refactoring insurance — safely tweak and improve code, catch mistakes early, and refactor with confidence.
Play With Confidence
17m 9sUse tests to experiment confidently: make small tweaks, run them, and iteratively improve your code without fear.
Sweat the Small Stuff
13m 19sImprove your codebase integrity by sweating small details - indentation, naming, and clean conditionals - to prevent bugs and keep code readable.
Be Strict With Your Controllers
16m 1sKeep controllers clean by sticking to seven RESTful actions—prevent bloated endpoints, improve clarity, and create a new controller when needed.
Drop Down a Level
23m 2sRefactor controller logic into the model: a friendly walkthrough of a problematic TeamMembersController (Technique #5) to simplify and test code.
An Alternative to Magic Numbers
3m 59sLearn how to replace confusing magic numbers with clear, named constants. Improve your code’s readability and maintainability with this simple technique!
Avoid Flags
5m 55sLearn why avoiding flags in your public interface leads to cleaner code. Discover how creating new methods can simplify functionality and improve maintainability!
The Strategy and Factory Patterns
9m 17sDiscover how to clean up messy controllers by combining Strategy and Factory patterns. Learn to organize code for better maintainability and clarity in Laravel apps!
Encapsulated UseCases
5m 26sLearn how to create encapsulated UseCase classes that represent key user actions, organizing all steps cleanly to build maintainable, clear Laravel apps.
Choose Your Class Names Wisely
6m 55sLearn why choosing clear, thoughtful class names matters and how it impacts your methods. Improve your code quality with this essential naming technique!




