Repository navigation
Naming Conventions
Kim Vinberg aKa Uldtot edited this page Nov 29, 2025
·
2 revisions
This document defines the naming conventions for database tables, columns, file names, and variables used in the wcioShop project.
The goal is to ensure consistency, clarity, and maintainability across the entire codebase.
Format
wcioshop_<entity> (snake_case, plural)
Rules
- Prefix
wcioshop_is used for all tables, including join tables. - Use snake_case and lowercase only.
- Use plural for all main entity tables (tables that store actual data objects).
- Use wcioshop_singular_singular for many-to-many join tables because each row represents a single relation between two entities.
Examples
wcioshop_users -- entity table (plural)
wcioshop_products -- entity table (plural)
wcioshop_orders -- entity table (plural)
wcioshop_order_items -- entity table (plural)
wcioshop_product_category -- join table (singular_singular)
Format
<entity>_<attribute> (snake_case, singular)
Rules
- Never use the project prefix in column names.
- Column names must always be singular.
- Primary keys:
-
idor<entity>_id(pick one standard).
-
- Foreign keys:
<referenced_entity>_id
Examples
id
user_id
product_id
first_name
created_at
updated_at
Format
snake_case.php
Rules
- Lowercase only.
- Words separated with underscores.
- No project prefix in file names.
- File name must describe the purpose of the file.
Examples
categories.php
category_edit.php
ajax_search.php
order_list.php
user_profile.php
Format
snake_case/
Examples
/ajax/search.php
/models/Product.php
/controllers/OrderController.php
Format
$variableName (camelCase)
Rules
- Always use camelCase for PHP variables.
- Use singular for single values, plural for arrays or collections.
- Use clear and descriptive names.
Examples
$userName
$orderTotal
$productList
$isActiveFormat
camelCase
Rules
- Use camelCase for variables and functions.
- Use PascalCase for classes.
- Use SCREAMING_SNAKE_CASE for constants.
Examples
let searchQuery;
const API_URL = "/api/v1/";
class ProductItem {}function getUserData() {}
function saveCategory() {}function loadUserData() {}
function updateCartItem() {}// Table
wcioshop_products
// Columns
id
name
price
created_at
// PHP variables
$productName = "T-shirt";
$productPrice = 149.00;
ajax_search.php
searchQuery
| Area | Format | Example |
|---|---|---|
| Table names | wcioshop_ | wcioshop_orders |
| Join tables | singular_singular | wcioshop_product_category |
| Columns | snake_case |
user_id, created_at
|
| PHP files | snake_case.php | ajax_search.php |
| PHP variables | camelCase | $orderTotal |
| JS variables | camelCase | orderTotal |
| JS constants | SCREAMING_SNAKE_CASE | API_URL |