phalcon/cphalcon · error · Phalcon\Mvc\Micro\Exceptions\HandlerNotCallable

'afterBinding' handler is not callable

Error message

'afterBinding' handler is not callable

What it means

Thrown by Micro::handle while running 'afterBinding' middleware when an entry is neither a MiddlewareInterface instance nor callable. Ensure every afterBinding handler is callable or implements MiddlewareInterface.

Solutions

  1. Register only callables or MiddlewareInterface implementations with afterBinding()
  2. Check that middleware factories are not returning null
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at phalcon/Mvc/Micro.zep:536 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/5a37a6acd1f86ae7. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Micro.zep:536

                    }
                }

                let afterBindingHandlers = this->afterBindingHandlers;

                let this->stopped = false;

                /**
                 * Calls the after binding handlers
                 */
                for afterBinding in afterBindingHandlers {
                    if typeof afterBinding === "object" && afterBinding instanceof MiddlewareInterface {
                        /**
                         * Call the middleware
                         */
                        let status = afterBinding->call(this);
                    } else {
                        if unlikely !is_callable(afterBinding) {
                            throw new HandlerNotCallable("afterBinding");
                        }

                        /**
                         * Call the afterBinding handler
                         */
                        let status = call_user_func(afterBinding);
                    }

                    /**
                     * Return the status if the middleware was stopped
                     */
                    if this->stopped {
                        return status;
                    }
                }

                /**
                 * Update the returned value

View on GitHub (pinned to b7419de9cd)