You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- If multiple solutions are available, consider the CRAP score
10
+
- Avoid duplication of code whenever possible: check for areas of the codebase that might already have similar code functionality
11
+
- Write code that takes into account the different environments: local, test, and production
12
+
- You are careful to only make changes that are requested or you are confident are well understood and related to the change being requested
13
+
- When fixing an issue or bug, do not introduce a new pattern or technology without first exhausting all options for the existing implementation. And if you finally do this, make sure to remove the old implementation afterwards so we don’t have duplicate logic
14
+
- Keep the codebase very clean and organized. Follow Laravel principles and file structure
15
+
- Avoid storing scripts in files if possible, especially if the script is likely only to be run once
16
+
- Avoid huge files over 200-300 lines of code. Refactor at that point
17
+
- Mock data if data is only needed for tests, never mock data for production environment
18
+
- Use factories for mock Eloquent Model data
19
+
- **Never** add stubbing or fake data patterns to code that affects local or production environments
20
+
- **Never** commit your .env file without first asking and confirming
7. **Implement proper API resource transformations.**
14
+
8. **Use Laravel's event and listener system for decoupled code.**
15
+
16
+
## Coding workflow
17
+
18
+
- **Focus on the areas of code relevant to the task**
19
+
- **Do not touch code that is unrelated to the task**
20
+
- **Write thorough tests for all major functionality**.
21
+
- **Write concise, technical responses with accurate PHP examples.**
22
+
- **Follow Laravel best practices and conventions.**
23
+
- **Use object-oriented programming with a focus on SOLID principles.**
24
+
- **Prefer iteration and modularization over duplication.**
25
+
- **Use descriptive variable and method names.**
26
+
- **Favor dependency injection and service containers.**
27
+
- **Avoid making major changes to the patterns and architecture of how a feature works, after it has shown to work well, unless explicitly structured**
28
+
- **Always think about what other methods and areas of code might be affected by code changes**
29
+
- **When using Actions for database operations, stick with model as the part of the namespace. Use appropriate nomenclature: Store{Model} for creating new records, Update{Model} for updating records, Destroy{Model} for deleting records. For example: `App\Actions\User\StoreUser`, `App\Actions\User\UpdateUser`, `App\Actions\User\DestroyUser`.**
30
+
- **When composing Blade components, if it requires a typed property, like an Eloquent model, always create a Component class.**
31
+
- **When composing Blade components, if the resulting view is shorter then 10 lines, consider using inline component**
32
+
- **Focus on the areas of code relevant to the task**
33
+
- **Do not touch code that is unrelated to the task**
34
+
35
+
36
+
## PHP and Laravel Core
37
+
- **Use PHP 8.3+ features when appropriate (e.g., typed properties, match expressions).**
38
+
- **Follow PSR-12 coding standards.**
39
+
- **Utilize Laravel's built-in features and helpers when possible.**
40
+
- **Follow Laravel's directory structure and naming conventions.**
41
+
- **Use lowercase with dashes for directories (e.g., `app/Http/Controllers`).**
42
+
- **Implement proper error handling and logging:**
43
+
- **Use Laravel's exception handling and logging features.**
44
+
- **Create custom exceptions when necessary.**
45
+
- **Use try-catch blocks for expected exceptions.**
46
+
- **Use Laravel's validation features for form and request validation.**
47
+
- **Implement middleware for request filtering and modification.**
48
+
- **Utilize Laravel's Eloquent ORM for database interactions.**
49
+
- **Use Laravel's query builder for complex database queries.**
50
+
- **Implement proper database migrations and seeders.**
51
+
52
+
## Laravel Best Practices
53
+
- **Use Eloquent ORM instead of raw SQL queries when possible.**
54
+
- **Implement Repository pattern for data access layer.**
55
+
- **Use Laravel's built-in authentication and authorization features.**
56
+
- **Utilize Laravel's caching mechanisms for improved performance.**
57
+
- **Implement job queues for long-running tasks.**
58
+
- **Use Laravel's built-in testing tools (PHPUnit, Pest, Dusk) for unit and feature tests.**
59
+
- **Implement API versioning for public APIs.**
60
+
- **Use Laravel's localization features for multi-language support.**
61
+
- **Implement proper CSRF protection and security measures.**
62
+
- **Use Laravel Mix for asset compilation.**
63
+
- **Implement proper database indexing for improved query performance.**
64
+
- **Use Laravel's built-in pagination features.**
65
+
- **Implement proper error logging and monitoring.**
66
+
- When writing code, strive to type-hint every parameter and type-hint return.
67
+
- When writing code, avoid unnecessary docBlocks when parameters are type-hinted
68
+
- When writing code, when necessary, provide simple and easy to understand method description
69
+
- When wriring Eloquent queries, consider using tappable scopes to avod leaking internals. For example, instead of writing `->whereNull('user_id')`, consider `->tap(new Orphan())` and write a tappable scope like this:
- **Implement small, focused Alpine.js components for specific UI interactions.**
92
+
- **Combine Alpine.js with Livewire for enhanced interactivity when necessary.**
93
+
- **Keep Alpine.js logic close to the HTML it manipulates, preferably inline.**
94
+
95
+
## Tailwind CSS Styling
96
+
- **Utilize Tailwind's utility classes for responsive design.**
97
+
- **Implement a consistent color scheme and typography using Tailwind's configuration.**
98
+
- **Use Tailwind's `@apply` directive in CSS files for reusable component styles.**
99
+
- **Optimize for production by purging unused CSS classes.**
100
+
101
+
## Performance Optimization
102
+
- **Implement lazy loading for Livewire components when appropriate.**
103
+
- **Use Laravel's caching mechanisms for frequently accessed data.**
104
+
- **Minimize database queries by eager loading relationships.**
105
+
- **Implement pagination for large data sets.**
106
+
- **Use Laravel's built-in scheduling features for recurring tasks.**
107
+
108
+
## Security Best Practices
109
+
- **Always validate and sanitize user input.**
110
+
- **Use Laravel's CSRF protection for all forms.**
111
+
- **Implement proper authentication and authorization using Laravel's built-in features.**
112
+
- **Use Laravel's prepared statements to prevent SQL injection.**
113
+
- **Implement proper database transactions for data integrity.**
114
+
115
+
## Testing
116
+
- **Write functional tests for every class.**
117
+
- **Implement feature tests for Livewire components using Laravel's testing tools.**
118
+
- **Ensure 100% coverage.**
119
+
- **Write Pest tests only.**
120
+
- When writing tests make sure to match the namespace, for example for `App\Components\ProgramLocationLookup\ProgramLocationLookupManager` the test should be
0 commit comments