phalcon/cphalcon · error · Phalcon\Container\Exceptions\NoProcessorFound

No processor found for the given definition

Error message

No processor found for the given definition

What it means

set() turns a raw definition into a ServiceDefinition by running an ordered processor list: ObjectProcessor (any non-Closure object), ClosureProcessor, and StringProcessor (a string naming an existing class). NoProcessorFound means the value matched none of these — arrays, int/float/bool scalars, null, resources, and strings that are not loadable class names are all rejected.

Source

Thrown at phalcon/Container/Container.zep:699

    /**
     * Locate a processor
     *
     * @param mixed $definition
     *
     * @return Processor
     * @throws NoProcessorFound
     */
    private function findProcessor(var definition) -> <Processor>
    {
        var processor;

        for processor in this->processors {
            if (processor->canProcess(definition)) {
                return processor;
            }
        }

        throw new NoProcessorFound();
    }

    /**
     * Resolve the service
     *
     * @param string $name
     * @param bool   $cache
     *
     * @return mixed
     * @throws ServiceNotFound
     * @throws ReflectionException
     */
    private function resolve(string name, bool cache) -> mixed
    {
        var definition, instance, lifetime;

        if (!array_key_exists(name, this->services)) {
            if (this->autowire && class_exists(name)) {

View on GitHub (pinned to b7419de9cd)

Solutions

  1. For values and arrays use parameters: $container->setParameter('debug', true)
  2. For class-name strings verify the class exists first: class_exists($class) — fix namespaces or install the package
  3. For computed values pass a closure: $container->set('x', fn () => computeX())
  4. Pre-built objects (any non-Closure object) are accepted as-is and returned on every get()

Example fix

// before
$container->set('config', ['debug' => true]); // NoProcessorFound

// after
$container->setParameter('config', ['debug' => true]);
Defensive patterns

Strategy: type-guard

Type guard

use Closure;

function isRegistrableDefinition(mixed $definition): bool
{
    if ($definition instanceof Closure) {
        return true; // ClosureProcessor
    }
    if (is_object($definition)) {
        return true; // ObjectProcessor
    }
    return is_string($definition) && class_exists($definition); // StringProcessor
}

// $container->set('x', $def) only when isRegistrableDefinition($def)

Try / catch

use Phalcon\Container\Exceptions\NoProcessorFound;

try {
    $container->set('debug', true);
} catch (NoProcessorFound $e) {
    $container->setParameter('debug', true); // route values to the parameter store
}

Prevention

When it happens

Trigger: $container->set('config', ['app' => [...]]); $container->set('debug', true); or $container->set('logger', 'Monolog\Logger') when that class does not exist (package not installed, namespace typo); passing a bare string constant like 'db.host'.

Common situations: Porting array-style definitions from Phalcon\Di\DI register() into the new Container; values that belong in setParameter(); composer dependency missing so class_exists() returns false for a class-name definition.

Related errors


AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21). Data as JSON: /api/errors/ca532db8ea271a81. Report an issue: GitHub.