Browse all series
TechniquesIntermediate10 episodes

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 4s

Use tests as refactoring insurance — safely tweak and improve code, catch mistakes early, and refactor with confidence.

Play With Confidence

17m 9s

Use tests to experiment confidently: make small tweaks, run them, and iteratively improve your code without fear.

Sweat the Small Stuff

13m 19s

Improve 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 1s

Keep 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 2s

Refactor 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 59s

Learn how to replace confusing magic numbers with clear, named constants. Improve your code’s readability and maintainability with this simple technique!

Avoid Flags

5m 55s

Learn 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 17s

Discover 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 26s

Learn 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 55s

Learn why choosing clear, thoughtful class names matters and how it impacts your methods. Improve your code quality with this essential naming technique!

Continue learning

Thumbnail for How to Build Command-Line Apps
How to Build Command-Line Apps

With Jeffrey Way

  • 6 episodes
  • Intermediate
  • Techniques
Thumbnail for Crafting Vue Modals
Crafting Vue Modals

With Pascal Baljet

  • 14 episodes
  • Advanced
  • Techniques
Thumbnail for Professional PHP Workflow in Sublime Text 3
Professional PHP Workflow in Sublime Text 3

With Jeffrey Way

  • 11 episodes
  • Intermediate
  • Tooling
Thumbnail for Mastering Permissions in Laravel
Mastering Permissions in Laravel

With Jeremy McPeak

  • 17 episodes
  • Advanced
  • Techniques
Thumbnail for Jeremy's Larabits
Jeremy's Larabits

With Jeremy McPeak

  • 29 episodes
  • Intermediate
  • Techniques

Would you like to hear from Laracasts by email occasionally?