Naming Conventions
Laravel
| What | How | Good | Bad |
|---|---|---|---|
| Blade | kebab-case | @include('top-header') |
|
| Collections | Plural, camelCase | activeUsers |
|
| Commands | kebab-case | send-email |
|
| Config | kebab-case | google-gmail.php |
|
| Controllers | Singular | UserController |
|
| Functions | snake_case | get_user |
|
| Methods | camelCase | getUsers |
|
| Models | Singular | User |
|
| Route Names | snake w/ dot notation | articles.show_user |
|
| Routes | Plural | articles/1 |
|
| Tables | Plural | users |
|
| URLs | kebab-case | /about-us |
|
| Variables | camelCase | user |
|
| Views | snake_case | show_user.blade.php |
For PHP, see PHP Naming.
Actions
Must be named using the following pattern:
- Verb + Noun(s) + (Optional) Context
- Description in the present tense
- Use the singular noun when referring to a single resource
- Use the plural noun when referring to a collection of resources
- Do not use the word "Action" as a suffix
- Use
executeas the primary method name
Verbs
| Verb | Description |
|---|---|
Get |
Retrieve |
Create |
Create |
Update |
Update |
Delete |
Delete |
Fetch |
Retrieve from remote |
Send |
Send to remote |
Sync |
Synchronize |
Import |
Import |
Export |
Export |
Validate |
Validate |
Other verbs can be used as long as they are clear and concise.
Examples
- GetUser
- UpdateUserLastLogin
- SendArticlesToNewsAPI
Batches and Pipelines
See Batches vs Pipelines for more information.
Must be named using the following pattern:
- Verb + Noun(s) + (Optional) Context
- Description in the present tense
- Use the singular noun when referring to a single resource
- Use the plural noun when referring to a collection of resources
- Use
handleas the primary method name