-
Function Duplication:
- Before creating a function, verify it doesn't already exist. If it does, collaborate with the original author to enhance its versatility.
-
Data Types:
- Utilize native data types when creating functions for greater flexibility. Example:
function getUser(int $user_id)
.
- Utilize native data types when creating functions for greater flexibility. Example:
-
Code Formatting:
- Always format code post-typing.
-
Import Sorting:
- Organize imports neatly.
-
SOLID Principles:
- Adhere to SOLID principles with emphasis on:
- S: Single Responsibility Principle
- I: Interface Segregation Principle
- Adhere to SOLID principles with emphasis on:
-
Controller Naming:
- Resource controllers should be plural (e.g.,
UsersController
). - Generic controllers should be singular (e.g.,
PaymentController
). - Apply this rule to view folders as well.
- Resource controllers should be plural (e.g.,
-
Variable Naming:
- Service names:
userService
- Regular variables:
$regular_var
- Service names:
-
Naming Conventions:
- Helpers, Services, and related naming should be based on singular Models. For practical examples, review the naming in this repository's directories and files.
-
Resource Function Naming:
- Align custom method names with resource function names for clarity, e.g., login ->
create()
, authenticate ->store()
. Use comments for clarity, avoiding docblocks.
- Align custom method names with resource function names for clarity, e.g., login ->
-
Function Signatures:
- Specify data types and return types in functions.
-
Routing:
- Employ consistent routing patterns for IDE recognition, e.g.,
Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy');
- Employ consistent routing patterns for IDE recognition, e.g.,
-
Proper Use Cases:
- Properly utilize helpers, services, traits, repositories, and interfaces according to their intended use.
- Services: Encapsulate core business logic separate from UI and database interactions.
- Traits: Provide reusable methods for multiple classes without inheriting functionality.
- Helpers: Offer utility functions for tasks like date formatting, remaining lightweight.
- Repositories: Abstract data access, controlled via interfaces for maintainability.
- Interfaces: Define contracts for functionalities, ensuring consistency and structure.
- Eager Loading: Manage through repositories, using a relations parameter.
- Route Model Binding: Custom logic via
resolveRouteBinding
using the repository pattern. - Form Requests: Use for validation and pre-processing of data for insert or update operations.
- API Resources: Utilize for data transformation post-query to standardize API responses.
- Laravel Jobs and Queues: Manage multiple emails and heavy jobs via Laravel jobs and queues.
- Events and Listeners: Implement for tasks post-business logic execution to maintain clean code.
- Policies and Gates: Use consistently for function access checks.
- Standard Components:
- Develop standard components within a designated folder.
- Indentation:
- Maintain 2 spaces for indentation.
- Component-Based Development:
- Emphasize readability and brevity through component-based development.
- Frontend Folder Structure
- Users
- create.blade.php
- edit.blade.php
- index.blade.php
- Frontend Folder Structure
- Users
- Create
- index.blade.php
- confirm.blade.php
- complete.blade.php
- Create
- Function Testing:
- Ensure main processes are thoroughly tested.
- Scenario Testing:
- Include tests for complex scenarios.
- Database Factories:
- Utilize database factories and states for testing.
- Blade Files: Use underscores (e.g.,
user_profile.blade.php
). - React Files: Use PascalCase (e.g.,
UserProfile.jsx
).