phalcon/cphalcon · error · Phalcon\Mvc\Model\Exceptions\HandlerMustImplementBindable

Handler must implement…

Error message

Handler must implement Phalcon\Mvc\Model\Binder\BindableInterface in order to use Phalcon\Mvc\Model as parameter

What it means

Thrown by Phalcon\Mvc\Model\Binder::bindToHandler when a route handler uses a Phalcon\Mvc\Model type-hint parameter but the handler implements neither BindModelInterface (static getModelName) nor BindableInterface (instance getModelName), leaving the binder with no way to resolve which model class to instantiate for the parameter.

Solutions

  1. Make the handler implement Phalcon\Mvc\Model\Binder\BindableInterface and implement getModelName() returning the model class name (or an array keyed by parameter name)
  2. Alternatively implement Phalcon\Mvc\Model\Binder\BindModelInterface with a static getModelName() when the handler cannot be instantiated
  3. Instead of type-hinting the base Phalcon\Mvc\Model, type-hint the concrete model class so no binder lookup is needed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Mvc/Model/Binder.zep:223 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/f15cead5bf6e3e15. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Model/Binder.zep:223

            let className = reflectionClass->getName();

            if !isset params[paramKey] {
                let paramKey = paramsKeys[paramKey];
            }

            let boundModel = null;
            let paramValue = params[paramKey];

            if className == Model::class {
                if realClasses == null {
                    if handler instanceof BindModelInterface {
                        let handlerClass = get_class(handler);
                        let realClasses = {handlerClass}::getModelName();
                    } elseif handler instanceof BindableInterface {
                        let realClasses = handler->getModelName();
                    } else {
                        throw new HandlerMustImplementBindable();
                    }
                }

                if typeof realClasses == "array" {
                    if unlikely !fetch className, realClasses[paramKey] {
                        throw new MissingModelClassName(paramKey);
                    }

                    let boundModel = this->findBoundModel(paramValue, className);
                } elseif typeof realClasses == "string" {
                    let className = realClasses;
                    let boundModel = this->findBoundModel(paramValue, className);
                } else {
                    throw new InvalidGetModelNameReturn();
                }
            } elseif is_subclass_of(className, Model::class) {
                let boundModel = this->findBoundModel(paramValue, className);
            }

View on GitHub (pinned to b7419de9cd)