phalcon/cphalcon · error · Phalcon\Mvc\Dispatcher\Exceptions\ResponseServiceUnavailable

EXCEPTION_NO_DI

EXCEPTION_NO_DI

Error message

A dependency injection container is required to access the 'response' service

What it means

Dispatcher::throwDispatchException() needs the shared 'response' service to build an error response, but the dispatcher has no DI container attached (and no default exists), so the service cannot be resolved.

Solutions

  1. Set a DI container on the dispatcher (or establish a default one) before dispatch
  2. Ensure the dispatcher is resolved from the DI rather than new'ed directly
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at phalcon/Mvc/Dispatcher.zep:222 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/789c276888166bc6. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Mvc/Dispatcher.zep:222

        if typeof eventsManager == "object" {
            if eventsManager->fire("dispatch:beforeException", this, exception) === false {
                return false;
            }
        }
    }

    /**
     * Throws an internal exception
     */
    protected function throwDispatchException( string message, int exceptionCode = 0)
    {
        var container, response, exception;

        let container = this->container;

        if container === null {
            throw new ResponseServiceUnavailable();
        }

        let response = <ResponseInterface> container->getShared("response");

        /**
         * Dispatcher exceptions automatically sends a 404 status
         */
        response->setStatusCode(404, "Not Found");

        /**
         * Create the real exception
         */
        let exception = new Exception(message, exceptionCode);

        if this->handleException(exception) === false {
            return false;
        }

View on GitHub (pinned to b7419de9cd)