Naming Conventions

Laravel

What How Good Bad
Blade kebab-case @include('top-header') @include('top_header')
Collections Plural, camelCase activeUsers active_users
Commands kebab-case send-email SendEmail
Config kebab-case google-gmail.php google_gmail.php
Controllers Singular UserController UsersController
Functions snake_case get_user getUser
Methods camelCase getUsers get_users
Models Singular User Users
Route Names snake w/ dot notation articles.show_user articles-show
Routes Plural articles/1 article/1
Tables Plural users user
URLs kebab-case /about-us /about_us
Variables camelCase user $user
Views snake_case show_user.blade.php showUser.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 execute as 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 handle as the primary method name
Previous
Home