PHPackages                             azaharizaman/nexus-human-resource-operations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. azaharizaman/nexus-human-resource-operations

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

azaharizaman/nexus-human-resource-operations
============================================

HR Operations Orchestrator - Coordinates all HR domain packages including Leave, Attendance, Payroll, Employee, Shift, Disciplinary, Performance Review, Training, Recruitment, and Onboarding

v0.1.0-alpha1(2mo ago)00MITPHP ^8.3

Since May 5Compare

[ Source](https://github.com/azaharizaman/nexus-human-resource-operations)[ Packagist](https://packagist.org/packages/azaharizaman/nexus-human-resource-operations)[ RSS](/packages/azaharizaman-nexus-human-resource-operations/feed)WikiDiscussions Synced 3w ago

READMEChangelogDependencies (16)Versions (2)Used By (0)

Nexus\\HumanResourceOperations
==============================

[](#nexushumanresourceoperations)

> **⚠️ REFACTORED (Dec 2025):** This orchestrator has been completely refactored to follow the **Advanced Orchestrator Pattern**.
>
> **📖 New Architecture:** See [NEW\_ARCHITECTURE.md](./NEW_ARCHITECTURE.md) for complete documentation.
>
> **📜 Previous Design:** See [README.OLD.md](./README.OLD.md) for historical reference.

---

Quick Start
-----------

[](#quick-start)

The HumanResourceOperations orchestrator coordinates HR workflows across multiple atomic packages using a clean, maintainable architecture.

### Core Components

[](#core-components)

- **Coordinators** - Traffic cops that orchestrate workflows
- **DataProviders** - Aggregate data from multiple packages
- **Rules** - Composable validation logic
- **Services** - Complex business operations
- **Workflows** - Long-running stateful processes
- **Listeners** - Reactive event handlers
- **DTOs** - Strict type contracts

### Example: Hiring Workflow

[](#example-hiring-workflow)

```
use Nexus\HumanResourceOperations\Coordinators\HiringCoordinator;
use Nexus\HumanResourceOperations\DTOs\HiringRequest;

$coordinator = $container->get(HiringCoordinator::class);

$request = new HiringRequest(
    applicationId: 'app-123',
    jobPostingId: 'job-456',
    hired: true,
    decidedBy: 'manager-789',
    startDate: '2025-01-01',
    positionId: 'senior-dev',
    departmentId: 'engineering',
);

$result = $coordinator->processHiringDecision($request);

if ($result->success) {
    echo "Employee hired: {$result->employeeId}";
    echo "User created: {$result->userId}";
} else {
    echo "Hiring failed: {$result->message}";
    print_r($result->issues);
}
```

### Example: Leave Application

[](#example-leave-application)

```
use Nexus\HumanResourceOperations\Coordinators\LeaveCoordinator;
use Nexus\HumanResourceOperations\DTOs\LeaveApplicationRequest;

$coordinator = $container->get(LeaveCoordinator::class);

$request = new LeaveApplicationRequest(
    employeeId: 'emp-123',
    leaveTypeId: 'annual-leave',
    startDate: '2025-01-10',
    endDate: '2025-01-15',
    reason: 'Family vacation',
    requestedBy: 'emp-123',
);

$result = $coordinator->applyLeave($request);

if ($result->success) {
    echo "Leave approved: {$result->leaveRequestId}";
    echo "New balance: {$result->newBalance} days";
}
```

---

Architecture Principles
-----------------------

[](#architecture-principles)

This orchestrator follows the **Advanced Orchestrator Pattern** with these golden rules:

1. **Coordinators are Traffic Cops, not Workers** - They direct flow, don't do work
2. **Data Fetching is Abstracted** - DataProviders aggregate cross-package data
3. **Validation is Composable** - Rules are individual, testable classes
4. **Strict Contracts** - Always use DTOs, never raw arrays
5. **System First** - Always use Nexus packages (Identity, Notifier, AuditLogger, etc.)

See [NEW\_ARCHITECTURE.md](./NEW_ARCHITECTURE.md) for complete details.

---

Directory Structure
-------------------

[](#directory-structure)

```
src/
├── Coordinators/       # Entry points for operations
├── DataProviders/      # Cross-package data aggregation
├── Rules/              # Validation constraints
├── Services/           # Complex business logic
├── Workflows/          # Stateful processes
├── Listeners/          # Event reactors
├── DTOs/               # Request/Response objects
├── Contracts/          # Interfaces
└── Exceptions/         # Domain errors

```

---

Available Coordinators
----------------------

[](#available-coordinators)

CoordinatorPurposeKey Operations`HiringCoordinator`Process hiring decisions`processHiringDecision()``LeaveCoordinator`Manage leave applications`applyLeave()`, `approveLeave()`, `cancelLeave()``AttendanceCoordinator`(Planned) Attendance tracking`recordCheckIn()`, `detectAnomalies()``PayrollCoordinator`(Planned) Payroll processing`calculatePayroll()`, `generatePayslip()`---

Authorization Policies
----------------------

[](#authorization-policies)

This orchestrator uses **`Nexus\Identity`** for context-aware authorization via `PolicyEvaluatorInterface`.

### Policy-Based Authorization (ABAC)

[](#policy-based-authorization-abac)

Complex authorization scenarios (e.g., "Can user apply leave on behalf of employee?") are handled by policies that check relationships and context:

```
use Nexus\Identity\Contracts\PolicyEvaluatorInterface;

// In ProxyApplicationAuthorizedRule
$canApply = $this->policyEvaluator->evaluate(
    user: $applicant,
    action: 'hrm.leave.apply_on_behalf',
    resource: null,
    context: [
        'target_employee_id' => $context->employeeId,
    ]
);
```

### Registering Policies

[](#registering-policies)

Policies must be registered in your application's service provider:

```
use Nexus\Identity\Contracts\PolicyEvaluatorInterface;
use Nexus\Identity\ValueObjects\Policy;
use Nexus\Hrm\Contracts\EmployeeQueryInterface;

public function boot(): void
{
    $policyEvaluator = $this->app->make(PolicyEvaluatorInterface::class);
    $employeeQuery = $this->app->make(EmployeeQueryInterface::class);

    // Register leave proxy policy
    $policy = Policy::define('hrm.leave.apply_on_behalf')
        ->description('User can apply leave on behalf of employees in same department or as manager')
        ->check(function($user, $action, $resource, $context) use ($employeeQuery) {
            $targetEmployeeId = $context['target_employee_id'] ?? null;
            if (!$targetEmployeeId) {
                return false;
            }

            $userEmployee = $employeeQuery->findByUserId($user->getId());
            $targetEmployee = $employeeQuery->findById($targetEmployeeId);

            if (!$userEmployee || !$targetEmployee) {
                return false;
            }

            // Same department OR user is manager
            return $userEmployee->getDepartmentId() === $targetEmployee->getDepartmentId()
                || $userEmployee->getId() === $targetEmployee->getManagerId();
        });

    $policyEvaluator->registerPolicy($policy->getName(), $policy->getEvaluator());
}
```

**📖 See:** [adapters/Laravel/HRM/docs/POLICY\_REGISTRATION\_EXAMPLE.md](../../../adapters/Laravel/HRM/docs/POLICY_REGISTRATION_EXAMPLE.md) for complete examples.

**📖 See:** [CODING\_GUIDELINES.md - Section 5.1](/CODING_GUIDELINES.md#51-authorization--policy-based-access-control) for authorization patterns.

---

Installation
------------

[](#installation)

```
composer require azaharizaman/nexus-human-resource-operations
```

Dependencies:

- `azaharizaman/nexus-hrm` - Employee management
- `azaharizaman/nexus-identity` - User accounts and authorization
- `azaharizaman/nexus-party` - Party records
- `azaharizaman/nexus-org-structure` - Organizational hierarchy
- `azaharizaman/nexus-leave` - Leave management
- `azaharizaman/nexus-notifier` - Notifications
- `azaharizaman/nexus-audit-logger` - Audit trails

---

Testing
-------

[](#testing)

```
# Unit tests (Rules, Services)
vendor/bin/phpunit tests/Unit

# Integration tests (Coordinators)
vendor/bin/phpunit tests/Integration
```

---

Migration Guide
---------------

[](#migration-guide)

If migrating from the old architecture:

1. **UseCases → Coordinators** - Entry points
2. **Pipelines → Workflows** - Long-running processes
3. **Inline validation → Rules** - Composable validation
4. **Array params → DTOs** - Typed contracts
5. **Direct repo calls → DataProviders** - Data aggregation

See [NEW\_ARCHITECTURE.md](./NEW_ARCHITECTURE.md) for complete migration guide.

---

License
-------

[](#license)

MIT License

---

**Documentation:**

- [New Architecture](./NEW_ARCHITECTURE.md) - Complete refactored design
- [Old Architecture](./README.OLD.md) - Historical reference
- [System Design Philosophy](/SYSTEM_DESIGN_AND_PHILOSOPHY.md) - Pattern rationale

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance84

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

81d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/117408?v=4)[Azahari Zaman](/maintainers/azaharizaman)[@azaharizaman](https://github.com/azaharizaman)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/azaharizaman-nexus-human-resource-operations/health.svg)

```
[![Health](https://phpackages.com/badges/azaharizaman-nexus-human-resource-operations/health.svg)](https://phpackages.com/packages/azaharizaman-nexus-human-resource-operations)
```

###  Alternatives

[symfony/lock

Creates and manages locks, a mechanism to provide exclusive access to a shared resource

515139.2M711](/packages/symfony-lock)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k54](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k46](/packages/civicrm-civicrm-core)[illuminate/broadcasting

The Illuminate Broadcasting package.

7127.2M221](/packages/illuminate-broadcasting)[logiscape/mcp-sdk-php

Model Context Protocol SDK for PHP

367116.8k12](/packages/logiscape-mcp-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
