Extension Structure
Understanding the extension structure is essential for developing IceHrm extensions. This guide covers the main components of an extension.
Directory Structure
Each extension follows a standard directory structure:
Main Components
Extension Entry File (kudos.php)
The main extension file is loaded during IceHrm initialization. It requires the essential classes:
- Extension.php (Extension Manager)
- Controller.php
- ApiController.php
- Migration files
Extension Manager (Extension.php)
The Extension class manages:
- Loading ORM database models
- Defining REST APIs
- Loading controllers
- Managing dashboard menu items
Controller Class
Handles communication between frontend and backend:
class Controller extends IceController
{
public function testAction($req): IceResponse
{
return new IceResponse(IceResponse::SUCCESS, 'response');
}
}
REST API (ApiController.php)
Exposes extension endpoints through a REST API interface.
Database Migrations
Located in src/Migrations/, these handle:
- Table creation
- Data seeding
- Migration up/down methods
ORM Models
Models extend BaseModel and reference database tables:
class EmployeeKudos extends BaseModel
{
public $table = 'EmployeeKudos';
}
Frontend Structure
The frontend is organized as follows:
web/
├── js/
│ ├── controller.js
│ ├── index.js
│ ├── module.js
│ └── view.js
└── index.php
The index.php entry point mounts React components. The Module class triggers showExtensionView() to render the main interface.
Technology Stack
- Frontend: React with Ant Design (version 4.x)
- Backend: PHP
- Database ORM: php-active-record
- UI Framework: Ant Design components