Skip to content

Hook Classes

LifecycleHook

Namespace:

php
PhpN8n\Client\Hooks\LifecycleHook

Enum cases:

CaseValue
BeforeWebhookRequestwebhook.before_request
AfterWebhookResponsewebhook.after_response
ExecutionReferenceCreatedexecution.reference_created
BeforeExecutionRefreshexecution.before_refresh
AfterExecutionRefreshexecution.after_refresh
BeforePollingStartsexecution.before_polling_starts
PollingAttemptexecution.polling_attempt
ExecutionStatusChangedexecution.status_changed
ExecutionSucceededexecution.succeeded
ExecutionFailedexecution.failed
ExecutionTimedOutexecution.timed_out
ExceptionThrownexception.thrown

HookContext

Namespace:

php
PhpN8n\Client\Hooks\HookContext

Carries hook name, context values, and optional exception.

Constructor

php
public function __construct(
    LifecycleHook $hook,
    array $context = [],
    ?Throwable $exception = null,
)

Methods

MethodReturns
hook()LifecycleHook
context()array<string, mixed>
exception()`Throwable

HookRegistry

Namespace:

php
PhpN8n\Client\Hooks\HookRegistry

Immutable hook registry and default HookRunnerContract implementation for callbacks.

Constructor

php
public function __construct(array $callbacks = [])

Methods

MethodReturns
on(LifecycleHook $hook, Closure $callback)HookRegistry
run(HookContext $hook)void

on() returns a new registry instance.

NullHookRunner

Namespace:

php
PhpN8n\Client\Hooks\NullHookRunner

No-op implementation of HookRunnerContract.

Methods

MethodReturns
run(HookContext $hook)void

Released under the MIT License.