phalcon/cphalcon · error · InvalidEventHandler
Event handler must be an Object or Callable
Error message
Event handler must be an Object or Callable
What it means
Events Manager attach() guard: the handler passed for an event type is neither an object nor a callable. Listeners must be objects (with a method named after the event), invokable objects, or plain callables.
Solutions
- Attach a valid listener object, Closure or callable string/array
- Ensure the handler variable is not null/false before attaching (check what your factory returned)
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at phalcon/Events/Manager.zep:243 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/a6d5f23cda77d75a.
Report an issue: GitHub.
Appendix: source
Thrown at phalcon/Events/Manager.zep:243
// Invokable object - generic callable.
let type = 3;
} else {
// Plain object - method named after the event. Capture
// the class name once at attach time so fireQueue() can
// skip get_class() per fire (type=2 tuples carry it).
this->insertHandlerEntry(
eventType,
handler,
2,
priority,
get_class(handler)
);
return;
}
} elseif is_callable(handler) {
let type = 3;
} else {
throw new InvalidEventHandler();
}
this->insertHandlerEntry(eventType, handler, type, priority);
}
/**
* Returns if priorities are enabled
*/
public function arePrioritiesEnabled() -> bool
{
return this->enablePriorities;
}
/**
* Removes every registered subscriber and detaches each listener they
* contributed. Listeners attached via attach() are untouched.
*
* Iterates a snapshot of `subscribers` so removeSubscriber() can safelyView on GitHub (pinned to b7419de9cd)