entities

Create OrangeHRM Doctrine ORM class entities with strict naming conventions.

1.1k|746|Updated Jan 5, 2017
One-click install
npx skills add https://github.com/orangehrm/orangehrm --skill entities-orangehrm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: entities
Source: https://github.com/orangehrm/orangehrm/tree/main/.agents/skills/entities
Command: npx skills add https://github.com/orangehrm/orangehrm --skill entities-orangehrm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

OrangeHRM uses a strict, custom Doctrine ORM setup with specific conventions for entity mapping, naming, and architecture that deviate from default Doctrine patterns. Defining entities without following these rules causes ORM discovery failures, broken relations, legacy compatibility issues, and inconsistent application behavior. This Skill eliminates guesswork by codifying all project-specific entity requirements and common pitfalls.

Core Features & Use Cases

  • Strict Convention Enforcement: Covers flat namespace requirements, docblock annotation-only mapping (no PHP 8 attributes), table naming rules (ohrm_ prefix for new tables, hs_hr_ for legacy 4.x imports), and ID strategy requirements (integer AUTO_INCREMENT only).
  • Complete Relation & Lifecycle Guidance: Includes mapping patterns for all relation types (ManyToOne, OneToMany, ManyToMany, OneToOne, self-referential M:N), EntityListener setup for sensitive field encryption, and the project-specific Decorator pattern for entity-adjacent logic with database access.
  • Edge Case & Pitfall Coverage: Addresses reserved column name quoting, legacy ENUM handling, NestedSet support for tree-shaped entities like Subunit, and common mistakes (uninitialized collections, wrong mappedBy/inversedBy usage, incorrect referencedColumnName for non-standard IDs like emp_number).
  • Use Case: Use this Skill when creating a new entity for an OrangeHRM feature (e.g. a new employee benefits table), adding relations to existing entities, setting up encryption for sensitive fields via EntityListeners, or debugging issues like null fields after load or broken lazy-loading relations.

Quick Start

Follow the entities skill guidelines to define a new Doctrine entity for your OrangeHRM feature with correct table naming, relation mappings, and collection initialization to avoid ORM configuration errors.

Frequently Asked Questions about entities

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Doctrine ORM entity in OrangeHRM without breaking relations?

To create a Doctrine ORM entity in OrangeHRM, use docblock annotation-only mapping, apply the flat namespace, prefix new tables with ohrm_, and initialize ArrayCollections to prevent broken relations.

Why does Doctrine lazy-loading fail after adding a new entity relation?

Doctrine lazy-loading in OrangeHRM fails when relation mappings use incorrect mappedBy or inversedBy values, or when referencedColumnName points to non-standard IDs like emp_number instead of the primary key.

Can I use PHP 8 attributes for Doctrine ORM mapping in OrangeHRM?

No, PHP 8 attributes cannot be used for ORM mapping in OrangeHRM; the system strictly requires docblock annotation-only mapping to ensure proper entity discovery and avoid configuration errors.

How do I set up sensitive field encryption in a Doctrine entity?

To set up sensitive field encryption in a Doctrine entity, configure an EntityListener to intercept hydration events, applying the project-specific architectural pattern for secure data handling.

What is the Decorator pattern for entity-adjacent database logic in OrangeHRM?

The Decorator pattern in OrangeHRM separates entity-adjacent database logic from the Doctrine entity class, allowing custom query and data access methods to operate alongside the mapped ORM structure.

How do I handle legacy table imports in OrangeHRM Doctrine entities?

For legacy 4.x table imports in OrangeHRM, prefix database table names with hs_hr_ instead of the standard ohrm_ prefix, and manage legacy ENUM columns using proper reserved name quoting.