Update dependencies
Composer: Laravel 13.43, Octane 2.25, Fortify 1.43 and Pest 5.3.7, with the packages they bring (70 in all). This fixes the advisories in Laravel and the Symfony components. npm: Vite 8.3.8 with Rolldown 1.2.19, Playwright 1.65.1 and chokidar 6. The asset build, CI and the dev container use Node.js 26. The dev image also has git for Composer. Both audits are clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Convention and Style Best Practices
|
||||
# Convention and style best practices
|
||||
|
||||
## Follow Project Naming Conventions
|
||||
## Follow project naming conventions
|
||||
|
||||
Prefer Laravel's conventions in new code, but preserve an established project convention unless a coordinated rename is worthwhile.
|
||||
|
||||
@@ -13,7 +13,7 @@ Prefer Laravel's conventions in new code, but preserve an established project co
|
||||
| Column | snake_case | `meta_title` |
|
||||
| Conventional foreign key | Singular model name plus `_id`, in snake_case | `article_id` |
|
||||
| Resource URI | Plural resource | `articles/1` |
|
||||
| Route name | Dotted segments; snake_case within a segment when needed | `users.show_active` |
|
||||
| Route name | Dotted segments, with snake_case within a segment when needed | `users.show_active` |
|
||||
| Method | camelCase | `getAll` |
|
||||
| Variable | camelCase | `$articlesWithAuthor` |
|
||||
| Collection | Descriptive and plural | `$activeUsers` |
|
||||
@@ -22,7 +22,7 @@ Prefer Laravel's conventions in new code, but preserve an established project co
|
||||
| Configuration file | snake_case | `google_calendar.php` |
|
||||
| Enumeration | Singular StudlyCase | `UserType` |
|
||||
|
||||
## Prefer Clear, Idiomatic Syntax
|
||||
## Prefer clear, idiomatic syntax
|
||||
|
||||
Use Laravel helpers and query methods when they communicate intent more directly. Do not shorten code when the result is ambiguous or loses useful type information.
|
||||
|
||||
@@ -39,9 +39,9 @@ Use Laravel helpers and query methods when they communicate intent more directly
|
||||
|
||||
Use typed request accessors such as `$request->string()`, `$request->integer()`, and `$request->boolean()` when their coercion matches the operation.
|
||||
|
||||
## Use Utilities When They Clarify Intent
|
||||
## Use utilities when they clarify intent
|
||||
|
||||
Laravel's `Str`, `Arr`, `Number`, and `Uri` utilities provide expressive operations and framework-consistent behavior. Prefer them when they are clearer or safer than an equivalent PHP operation, not as an unconditional replacement for every built-in function.
|
||||
Laravel's `Str`, `Arr`, `Number`, and `Uri` utilities provide expressive operations and framework-consistent behavior. Prefer them when they are clearer or safer than an equivalent PHP operation, not as a replacement for every built-in function.
|
||||
|
||||
```php
|
||||
$slug = Str::slug($title);
|
||||
@@ -57,7 +57,7 @@ $name = Arr::get($array, 'user.name', 'default');
|
||||
$public = Arr::only($attributes, ['name', 'email']);
|
||||
```
|
||||
|
||||
Use `Number` for localized display formatting rather than values that will be stored or calculated:
|
||||
Use `Number` for localized display formatting, not for values you store or calculate:
|
||||
|
||||
```php
|
||||
Number::format(1000000);
|
||||
@@ -65,20 +65,20 @@ Number::currency(1500, 'USD');
|
||||
Number::fileSize(1024 * 1024);
|
||||
```
|
||||
|
||||
Use `Uri` when constructing or transforming a uniform resource identifier (URI) benefits from a structured API:
|
||||
Use `Uri` when a structured API helps you build or transform a uniform resource identifier (URI):
|
||||
|
||||
```php
|
||||
$uri = Uri::of('https://example.com/search')
|
||||
->withQuery(['q' => 'laravel', 'page' => 1]);
|
||||
```
|
||||
|
||||
Check the documentation for the Laravel version supported by the project before using newer utility classes or methods.
|
||||
Before using newer utility classes or methods, check the documentation for the project's Laravel version.
|
||||
|
||||
## Keep Presentation Code Maintainable
|
||||
## Keep presentation code maintainable
|
||||
|
||||
Prefer the project's asset pipeline, components, and existing conventions for substantial JavaScript and Cascading Style Sheets (CSS). Small page-specific scripts or styles can be reasonable in Blade layouts or stacks; avoid mixing large behavior and style blocks into templates.
|
||||
Prefer the project's asset pipeline, components, and existing conventions for substantial JavaScript and Cascading Style Sheets (CSS). Small page-specific scripts or styles can be reasonable in Blade layouts or stacks. Avoid mixing large behavior and style blocks into templates.
|
||||
|
||||
Pass server data with an encoding mechanism appropriate to its context. For example, Blade's `Js::from()` safely formats data for JavaScript:
|
||||
Pass server data with an encoding that fits its context. For example, Blade's `Js::from()` safely formats data for JavaScript:
|
||||
|
||||
```blade
|
||||
<script>
|
||||
@@ -88,9 +88,9 @@ Pass server data with an encoding mechanism appropriate to its context. For exam
|
||||
|
||||
Data attributes are useful for small scalar values, but serializing a large model into an attribute can expose unnecessary fields and complicate escaping.
|
||||
|
||||
## Write Comments That Explain Why
|
||||
## Write comments that explain why
|
||||
|
||||
Prefer clear names and small units of code over comments that merely restate an operation. Add concise comments for non-obvious constraints, tradeoffs, workarounds, regular expressions, or external behavior that the code cannot express by itself. Keep comments accurate when behavior changes.
|
||||
Prefer clear names and small units of code over comments that restate an operation. Add concise comments for non-obvious constraints, tradeoffs, workarounds, regular expressions, or external behavior that the code cannot express by itself. Keep comments accurate when behavior changes.
|
||||
|
||||
Unhelpful:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user