phalcon/cphalcon · error · Phalcon\Di\Exceptions\ServiceCannotBeResolved

Service ' ' cannot be resolved

Error message

Service '{name}' cannot be resolved

What it means

Fires during Di->get() when the registered service instance could not be resolved (the service resolver returned null or resolution threw). The named service exists but its definition failed to produce an object.

Solutions

  1. Inspect the service definition (closure/className string) passed to set()/register() and fix it
  2. If it is a class name, ensure the class exists and is autoloadable before resolution
  3. Register the service with a valid resolver or set it directly with setService
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at phalcon/Di/Di.zep:220 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/110cdce4d658a949. Report an issue: GitHub.

Appendix: source

Thrown at phalcon/Di/Di.zep:220

         */
        if this->eventsManager !== null {
            let instance = this->eventsManager->fire(
                "di:beforeServiceResolve",
                this,
                [
                    "name":       name,
                    "parameters": parameters
                ]
            );
        }

        if instance === null {
            if service !== null {
                // The service is registered in the DI.
                try {
                    let instance = service->resolve(parameters, this);
                } catch ServiceResolutionException {
                    throw new ServiceCannotBeResolved(name);
                }

                // If the service is shared then we'll cache the instance.
                if isShared {
                    let this->sharedInstances[name] = instance;
                }
            } else {
                /**
                 * The DI also acts as builder for any class even if it isn't
                 * defined in the DI
                 */
                if unlikely !class_exists(name) {
                    throw Exception::serviceNotFound(name);
                }

                if typeof parameters == "array" && !empty parameters {
                    let instance = create_instance_params(name, parameters);
                } else {

View on GitHub (pinned to b7419de9cd)