- Laravel Coding Standards
Following best practices ensures maintainable, secure, and scalable applications.
a. Project Structure & Naming Conventions
Follow PSR-4 Autoloading standards.
Use camelCase for variables ($userProfile).
Use PascalCase for classes (UserController).
Use snake_case for database columns (created_at).
b. Controllers & Routes
Follow RESTful principles for API development.
Avoid writing business logic in controllers—use Service Classes.
Keep routes clean and group related routes in routes/web.php or routes/api.php.
c. Models & Database
Use Eloquent ORM for database interactions.
Define relationships in models (hasOne, hasMany).
Always use migrations for database schema changes.
d. Security & Validation
Use Laravel Validation ($request->validate()).
Protect routes using middleware (auth, verified).
Use CSRF protection (@csrf in forms).
e. Caching & Performance
Use caching (Redis, Memcached) for faster response times.
Optimize queries using Eager Loading (with()).
- Envato Guidelines for Laravel Applications
If you’re submitting to Envato (CodeCanyon), follow these:
a. Code Quality
Follow Laravel’s coding standards.
Avoid unnecessary or duplicate code.
b. File Structure
Keep separate folders for controllers, models, and views.
Include a config file for easy customization.
c. Documentation
Provide a README.md file with installation and setup instructions.
Include a changelog for updates.
d. Licensing & Compliance
Do not use unlicensed third-party assets (themes, images).
Provide correct author attribution for open-source libraries.
e. Security & Performance
Avoid hardcoded credentials (.env for sensitive data).
Implement SEO-friendly URLs.
- General Rules for Laravel Applications
Use Laravel Debugbar for performance monitoring.
Follow SOLID principles for maintainable code.
Always use Laravel Queues for background tasks.
Write unit tests for critical functionalities.