Laravel Coding Best Practices — 01

Image for post
Image for post

Naming

camelCase — must start with a lowercase letter and the first letter of every new subsequent word has its first letter capitalized and is compounded with the previous word.

snake_case — replacing all spaces with a “_” and lowercasing all the words.

kebab-case — replacing all spaces with a “-” and lowercasing all the words.

PascalCase — every word starts with an uppercase letter

Laravel variable naming Conventions

Name should be singular and pascal case

Example :- UserController, PostController

Name should be plural and snake case

Example :- users, user_posts

Name should be singular and snake case

Example :- id, post_content, created_at

Name should be camelCase

Example :- $users, $usersPosts

Name should be singular and pascal case

Example :- NewsPost, FormPost

Name should be snake case

Example :- user_home.blade.php, all_post.blade.php

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store