Skip to content

Naming Conventions

Kim Vinberg aKa Uldtot edited this page Nov 29, 2025 · 2 revisions

Naming Conventions – wcioShop Project

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.


1. Database Naming

1.1 Table Names

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)

1.2 Column Names

Format

<entity>_<attribute>  (snake_case, singular)

Rules

  • Never use the project prefix in column names.
  • Column names must always be singular.
  • Primary keys:
    • id or <entity>_id (pick one standard).
  • Foreign keys:
    • <referenced_entity>_id

Examples

id
user_id
product_id
first_name
created_at
updated_at

2. File Names

2.1 PHP Files

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

2.2 Directory Names

Format

snake_case/

Examples

/ajax/search.php
/models/Product.php
/controllers/OrderController.php

3. Variable Naming

3.1 PHP Variables

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
$isActive

3.2 JavaScript Variables

Format

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 {}

4. Function Names

PHP

function getUserData() {}
function saveCategory() {}

JavaScript

function loadUserData() {}
function updateCartItem() {}

5. Consistency Examples

Database → PHP

// Table
wcioshop_products

// Columns
id
name
price
created_at

// PHP variables
$productName = "T-shirt";
$productPrice = 149.00;

AJAX Example

ajax_search.php
searchQuery

6. Quick Reference

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

Clone this wiki locally