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

One of the registered handlers is invalid

Error message

One of the registered handlers is invalid

What it means

Micro::mount() guard: while registering the collection's handlers, one entry was not an array. Collections normalize each handler to [methods, pattern, handler]; a non-array entry means a custom/corrupted collection implementation.

Solutions

  1. Use the standard Collection which builds [method, pattern, handler] tuples
  2. Fix custom CollectionInterface implementations to yield arrays per handler
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at phalcon/Mvc/Micro.zep:809 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/34d5fe554722537f. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Micro.zep:809

        }

        /**
         * Check if handler is lazy
         */
        if collection->isLazy() {
            let lazyHandler = new LazyLoader(mainHandler);
        } else {
            let lazyHandler = mainHandler;
        }

        /**
         * Get the main prefix for the collection
         */
        let prefix = collection->getPrefix();

        for handler in handlers {
            if unlikely typeof handler !== "array" {
                throw new InvalidRegisteredHandler();
            }

            let methods    = handler[0];
            let pattern    = handler[1];
            let subHandler = handler[2];
            let name       = handler[3];

            /**
             * Create a real handler
             */
            let realHandler = [lazyHandler, subHandler];

            if !empty prefix {
                if pattern === "/" {
                    let prefixedPattern = prefix;
                } else {
                    let prefixedPattern = prefix . pattern;
                }

View on GitHub (pinned to b7419de9cd)