HR modules
OpenHR PH ships as a small core plus optional HR modules. Core HR — employees, organisation structure, attendance, leave, payroll and reports — is always on. The optional modules can be switched on only when a team uses them, so a new installation opens with a focused menu instead of every screen.
HrModule ── category, dependencies
│
ModuleCatalogue ── definitions, dependents, resources, cycle check
│
ModulePreset ── Core, Essentials, Talent, Compliance, Full
│
ModuleFlags ── Pennant global flags + .env pins + configured state
│
├─ Navigation (module AND group access AND company hide AND permission)
├─ ResourceRegistry (404, not just hidden)
├─ GlobalSearchService
└─ Dashboard metrics
Key files
| Concern | File |
|---|---|
| Module keys, categories, dependencies | app/Enums/HrModule.php |
| Module categories | app/Enums/ModuleCategory.php |
| Bundles offered at setup | app/Enums/ModulePreset.php |
| Definitions and dependency graph | app/Support/Features/ModuleCatalogue.php |
| Switch reads/writes and configured state | app/Support/Features/ModuleFlags.php |
| Per-group narrowing | app/Support/Features/ModuleAccess.php |
| Advisory usage signal | app/Support/Features/ModuleUsage.php |
| Menu filtering | app/Livewire/Admin/Support/Navigation.php |
| Resource routing gate | app/Livewire/Admin/Support/ResourceRegistry.php |
| Setup page | app/Livewire/Admin/Setup/Modules.php |
| Navigation pins | app/Livewire/Admin/Setup/NavigationPreferences.php |
| Settings toggle page | app/Livewire/Admin/Settings/Settings.php |
Visibility rule
An admin screen is visible only when all of these are true:
- The module is enabled for the installation.
- The user's group allows the module (an empty
groups.module_accessallows every enabled module). - The company has not hidden the menu entry (
companies.hidden_menu). - The entry's
canpermission key is granted to the group.
Navigation, ResourceRegistry, the command palette and dashboard cards all
use the same rule. Hiding a module therefore hides the menu entry, removes it
from search, and returns 404 from its URLs. No data is deleted, and switching
the module back on restores access to the same records.
Dependencies
Dependencies live on the enum:
public function dependsOn(): array
{
return match ($this) {
self::Separation, self::Retirement => [self::Employment],
default => [],
};
}
- Enabling a module also enables every prerequisite.
- Disabling a module that enabled modules depend on throws
ModuleDependencyExceptionunless a cascade is requested. ModuleCatalogue::hasCycle()is covered by a test; keep the graph acyclic.
Choosing modules
Three entry points write the same flags:
# Fresh install: Core only
php artisan openhr:install --sector=Private --country=PH --modules=core
# A bundle or a fine-grained list
php artisan openhr:install --sector=Private --country=PH --modules=essentials
php artisan openhr:install --sector=Private --country=PH --modules=recruitment,performance
# After installation
php artisan modules:preset full
php artisan modules:toggle recruitment disable
php artisan modules:toggle employment disable --cascade
php artisan modules:list
php artisan modules:usage --days=90
In the admin workspace, use Settings → HR Modules (the setup page) or
Settings → Features. Only a company owner or platform administrator can
change the installation selection; other administrators can review it. The
.env lists HR_MODULES_DISABLED and HR_MODULES_ENABLED pin a module for the
whole deployment and always win over stored values.
The Features page also offers Hide unused, which disables modules that have had no recorded usage in the idle window. It skips a prerequisite when one of its dependents is still in use, and it never deletes records.
Installation::KEY_MODULES_CONFIGURED_AT records whether an admin has chosen
the module set. Installations created before this setting existed keep every
module on until they run setup, so existing deployments do not lose menus on
upgrade.
Adding a module
- Add a case to
HrModulewith a category and, if needed, dependencies. - Tag each resource with
public static ?HrModule $module = HrModule::YourModule;. - Add the menu section or items to
config/admin.phpwith'module' => 'your-module'. - Add portal routes with the
module:your-modulemiddleware. - Add the module to any relevant
ModulePresetbundles. - Run
php artisan modules:listandphp artisan test tests/Feature/Hr.
Adding per-company hiding
Menu entries are keyed by resource key, link path or a slug of the label, and
whole sections use a slug of the section label. Companies → Hidden menu items
stores the keys on companies.hidden_menu. Hiding is presentation only: it
never changes module state, permissions or data.
Testing the matrix
The module suite lives in tests/Feature/Hr:
| Test | Covers |
|---|---|
ModuleCatalogueTest | Categories, dependencies, dependents, presets, cascade |
ModuleFeaturesTest | Installation switches, .env pinning, resources, portal |
ModuleSetupTest | Setup page, --modules, Core default |
ModuleNavigationTest | Empty sections, company hiding, pins, palette |
ModuleGroupAccessTest | Group narrowing, 404s, dashboard cards |
ModuleUsageTest | Recording, throttling, idle detection |
phpunit.xml forces HR_MODULES_DISABLED and HR_MODULES_ENABLED to empty so a
developer .env cannot pin modules during tests.