Appearance
Naming & Conventions
Predictable naming makes it easy to jump between PHP controllers, database tables, routes, and Angular views across any number of modules.
General principles
- Variables are nouns:
$userAge,$totalPrice,$openItems. - Functions & methods are verbs:
calculateTotal(),getUser(),submitForReview(). - Booleans ask a question: Prefix with
is,has, orcan— e.g.$isEnabled,hasAccess(),canApprove(). - Include units when non-obvious: Suffix with the unit — e.g.
$timeoutMs,$fileSizeKb,$durationDays,$coverMonths. - No structural words: Name classes
Order(notOrderClass), variables$count(not$countVariable) and$orders(not$ordersArray). Architectural role suffixes (Controller,Service,Repository,DTO,Exception) describe behavior and are expected.
Casing
| Style | Used for | Examples |
|---|---|---|
camelCase | Variables, functions, methods, properties, Angular props, $_POST / $_GET / $_SESSION keys | $totalPrice, getUser(), canChange, $_POST['dueDate'] |
PascalCase | Folders, PHP classes, interfaces, enums, traits, Angular components & directives | Core/Services/, OrderService, OrderStatus, OrderEditor |
snake_case | Database tables and columns, plus request keys mapping 1:1 to a column | order_lines, created_at, $_POST['order_id'] |
kebab-case | Angular component selectors and ?feature= / ?action= route names | orders-editor, ?feature=order-lines, ?action=save-stage |
File names
- Autoloaded PHP (classes, interfaces, enums, traits):
PascalCase.phpmatching the symbol name (OrderService.php). - Directly included PHP (entry points & config):
snake_case.php(index.php,access_config.php,flag_config.php). - TypeScript:
- Angular component:
<Name>.component.ts(PascalCase) - Angular directive:
<Name>.ts(PascalCase) - Helper/utility module:
camelCase.tsnamed after its main export (postForm.ts,runStep.ts,dates.ts) - Prop types:
<module>.types.ts(orders.types.ts,notes.types.ts)
- Angular component:
Class & component names
| Kind | Rule | Examples |
|---|---|---|
| Controller | <Name>Controller (may be plural to match route) | OrdersController, NotesController |
| Service | <Name>Service, singular | OrderService, NoteService |
| Repository | <Name>Repository, singular | OrderRepository, OrderLookupsRepository |
| DTO | <Name>DTO | NewOrderDTO, OrderFormDTO, OrderDTO |
| Exception | <Name>Exception | OrderLockedException, OrderNotFoundException |
| Enum | No suffix, singular | OrderStatus, NotePriority |
| Interface | No suffix | DashboardProvider, QualityFeature |
| Schema | Table name in PascalCase, no suffix | OrderLines, Notes |
| Seed | <Table>Seed | NoteCategoriesSeed, OrderStatusesSeed |
| Page (View) | No suffix in Views/<Name>/<Name>.component.ts; <Name>List for registers | Order, OrderList, OrderForm |
| Component | No suffix in <Name>.component.ts | OrderEditor, OrderDialog |
| Page props builder | <Name>Page in UI/ | OrderPage, NotePage |
Prefix classes and selectors with the module name
Name classes OrderAttachmentRepository (not AttachmentRepository) and Angular selectors orders-editor (not editor) so names stay unique when files from multiple modules are open or imported together.