# file.naming.rules.md v1

## Rules
1. All lowercase
2. No dash - , no underscore _
3. Dots . separate logical parts, last dot before extension
4. Extension is last part: .php, .js, .json, .css, .md

## Good Examples
- admin.tool.php (admin + tool)
- audit.tool.php
- bootstrap.core.php
- database.core.php
- header.inc.php
- app.config.json
- system.config.json
- main.js
- style.css
- readme.md

## Bad Examples
- admin_tool.php (underscore)
- admin-tool.php (dash)
- Admin.Tool.php (uppercase)
- bootstrap_core.php (underscore)
- app-config.json (dash)

## Why Dots?
- Allows grouping: *.tool.php = all tools, *.core.php = all core, *.lib.php = all libs, *.inc.php = all includes
- Easy to search: ls *.tool.php
- Matches app IDs: games.hangman -> file games.hangman not games_hangman

## App IDs
App IDs use dots: category.name = games.hangman, tools.auth
Matches folder path: websites/apps/games/hangman but ID is games.hangman
Registry maps ID to path, so rename only in registry.

## Exceptions
- index.php is allowed (single word, no dot needed)
- Standard files like .htaccess allowed but avoid if possible
- Docs: readme.md, changelog.md are okay lowercase
# file.naming.rules.md v1.3.0 - Updated Rules

## File Naming Rules (Strict)

1. **All lowercase**
2. **No dash `-`, no underscore `_`, no double underscore `__`**
3. **Dots `.` separate logical parts, last dot before extension**
4. **Extension is last part: .php, .js, .json, .css, .md**

Good:
- admin.tool.php (admin + tool)
- bootstrap.core.php (bootstrap + core)
- app.config.json (app + config)
- main.js, style.css, readme.md

Bad:
- admin_tool.php (underscore)
- admin-tool.php (dash)
- Admin.Tool.php (uppercase)
- bootstrap__core.php (double underscore)
- my__file.php (__)

Why dots? Allows grouping: `*.tool.php`, `*.core.php`, `*.lib.php`, `*.inc.php`, search `ls *.tool.php`, matches app IDs `games.hangman`.

## Code Naming Rules (PHP, JS, HTML) - Strict camelCase

1. **Function names:** camelCase, no dots, no dash, no underscores
   Good: `sysPath()`, `appUrl()`, `authCheck()`, `csrfToken()`, `dbConnect()`
   Bad: `sys.path()`, `sys_path()`, `sys-path()`, `sys__path()`

2. **Variable names:** camelCase, no dots, dash, underscores
   Good: `$appId`, `$systemRoot`, `$userId`, `$baseUrl`
   Bad: `$app_id`, `$system_root`, `$app.id`, `$app-id`, `$app__id`

3. **No `__` double underscore anywhere in filenames or code identifiers**
   Bad: `__construct`, `__FILE__` is allowed only as PHP magic constant, but avoid custom `__`

4. **Constants:** Use camelCase or UPPER without underscore? We use camelCase variables instead of constants to avoid underscores. Example: `systemRoot` not `SYSTEM_ROOT`.

5. **Why?** Dots in function names are invalid PHP syntax (`sys.path()` causes parse error). Underscores and dashes break camelCase consistency. Double underscores cause confusion with PHP magic methods.

## App IDs

App IDs use dots: `category.name` = `games.hangman`, `tools.auth`
Matches folder path `websites/apps/games/hangman` but ID is `games.hangman`
Registry maps ID to path, so rename only in registry.

## Exceptions

- `index.php` allowed (single word, no dot needed)
- Magic constants `__FILE__`, `__DIR__` allowed but not custom
- Docs `readme.md`, `changelog.md` lowercase
