Skip to content

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, or can — 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 (not OrderClass), variables $count (not $countVariable) and $orders (not $ordersArray). Architectural role suffixes (Controller, Service, Repository, DTO, Exception) describe behavior and are expected.

Casing ​

StyleUsed forExamples
camelCaseVariables, functions, methods, properties, Angular props, $_POST / $_GET / $_SESSION keys$totalPrice, getUser(), canChange, $_POST['dueDate']
PascalCaseFolders, PHP classes, interfaces, enums, traits, Angular components & directivesCore/Services/, OrderService, OrderStatus, OrderEditor
snake_caseDatabase tables and columns, plus request keys mapping 1:1 to a columnorder_lines, created_at, $_POST['order_id']
kebab-caseAngular component selectors and ?feature= / ?action= route namesorders-editor, ?feature=order-lines, ?action=save-stage

File names ​

  • Autoloaded PHP (classes, interfaces, enums, traits): PascalCase.php matching 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.ts named after its main export (postForm.ts, runStep.ts, dates.ts)
    • Prop types: <module>.types.ts (orders.types.ts, notes.types.ts)

Class & component names ​

KindRuleExamples
Controller<Name>Controller (may be plural to match route)OrdersController, NotesController
Service<Name>Service, singularOrderService, NoteService
Repository<Name>Repository, singularOrderRepository, OrderLookupsRepository
DTO<Name>DTONewOrderDTO, OrderFormDTO, OrderDTO
Exception<Name>ExceptionOrderLockedException, OrderNotFoundException
EnumNo suffix, singularOrderStatus, NotePriority
InterfaceNo suffixDashboardProvider, QualityFeature
SchemaTable name in PascalCase, no suffixOrderLines, Notes
Seed<Table>SeedNoteCategoriesSeed, OrderStatusesSeed
Page (View)No suffix in Views/<Name>/<Name>.component.ts; <Name>List for registersOrder, OrderList, OrderForm
ComponentNo suffix in <Name>.component.tsOrderEditor, 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.

Labmin LIMS Module Developer Documentation