Declaring Hook Providers
Declare hook or event providers from the addon that owns the behavior. The declaration should tell Installer, system governance, and developers what function is called, where it lives, and what lifecycle boundary applies.
Provider declaration shape
A provider declaration should include these fields:
- hook or event key: dotted lowercase name with at least three segments
- provider key: addon machine key, such as `template_manager`
- handler reference: function or callable reference
- path: PHP file that defines the handler
- signature: expected arguments and return type
- boundary: what the handler may and may not own
Template Manager shows the practical pattern in `addons/template_manager/bootstrap/install_contract.php` and `addons/template_manager/manifest.php` through `installer_hooks.after_generated_template_package_deployed`.
'installer_hooks' => [
'after_generated_template_package_deployed' => [
'function' => 'amv_template_manager_register_installed_package',
'path' => 'addons/template_manager/src/template_repository.php',
'signature' => 'amv_template_manager_register_installed_package(PDO $pdo, string $packagePath, array $manifest, array $context = []): array',
'lifecycle_boundary' => 'Installer/system governance deploy the package first; Template Manager only records installed-template metadata and contracts.',
],
],That legacy install hook name is underscore-based inside the manifest contract. New Core runtime hook names should use the dotted validator shape, for example `template.package.after_deploy`.
Provider responsibilities
The provider must keep its behavior inside its addon boundary. A Template Manager hook may register installed template metadata. It must not copy package files, run installer rollback, or take over system governance lifecycle state.
Mistakes to avoid
- Do not declare broad speculative hooks before a known integration needs them.
- Do not place addon business logic in Core just because Core owns dispatch.
- Do not expose a handler without documenting its payload contract.
- Do not use events as the only proof that a sensitive mutation happened.
Updated: 2026-05-07 02:18:09
Backlinks
No published pages link here yet.