Follow proven patterns to structure a Laravel app so other developers can read and maintain it easily
Avoid the N+1 query performance trap when loading related data in Laravel pages
Move validation, business logic, and database queries into the right classes as experienced Laravel developers expect
This repository is a guide to writing clean, well-organized code in Laravel, a popular PHP framework used to build web applications. Rather than teaching Laravel from scratch, it collects a set of opinionated rules and patterns that experienced Laravel developers follow to keep projects readable and easy to maintain over time. Each section in the guide focuses on one principle, usually illustrated with two code examples side by side: one labeled "Bad" showing a common mistake, and one labeled "Good" showing the recommended approach. The principles covered include keeping each class or method focused on a single task, putting database query logic inside the data model instead of the controller, moving validation rules into their own classes, and placing business logic in dedicated service classes rather than scattering it throughout the application. Other sections address more specific habits: avoiding repeated code, using Laravel's built-in data querying tool called Eloquent instead of raw SQL, and preventing a common performance trap known as the N+1 problem (where a page accidentally fires dozens of database queries by loading related data one piece at a time). There are also sections on chunking large data sets to avoid memory limits, using descriptive method and variable names, keeping HTML and CSS out of server-side template files, storing configuration values in dedicated files rather than hardcoding strings in code, and following Laravel's own naming conventions so that any developer familiar with the framework can read any Laravel project without extra context. The guide is available in over 20 languages, including Chinese, Japanese, Russian, Portuguese, Arabic, and several others, reflecting how widely read it is across the global developer community.
← alexeymezenin on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.