{"record":{"id":"f640208ba1003014","repo":"phalcon/cphalcon","slug":"cannot-resolve-a-fresh-name-it-is-not-registe","errorCode":null,"errorMessage":"Cannot resolve a fresh '{name}': it is not registered in the Di and is not an existing class","messagePattern":"Cannot resolve a fresh '(.+?)': it is not registered in the Di and is not an existing class","errorType":"exception","errorClass":"Phalcon\\Container\\Exceptions\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Auth/Internal/ContainerResolver.zep","lineNumber":127,"sourceCode":"    public static function resolveFresh(var container, string name) -> object\n    {\n        var e;\n\n        self::ensureContainer(container);\n\n        if (container instanceof Collection) {\n            if (true !== container->has(name)) {\n                throw new ContainerException(\n                    \"Cannot resolve a fresh '\" . name\n                    . \"': it is not bound in the container\"\n                );\n            }\n\n            return container->{\"new\"}(name);\n        }\n\n        if (true !== container->has(name) && !class_exists(name)) {\n            throw new ContainerException(\n                \"Cannot resolve a fresh '\" . name\n                . \"': it is not registered in the Di and is not an existing class\"\n            );\n        }\n\n        try {\n            return container->get(name);\n        } catch DiException, e {\n            throw new ContainerException(\n                \"Failed to resolve '\" . name . \"' from the Di container\",\n                0,\n                e\n            );\n        }\n    }\n\n    /**\n     * Builds the ordered candidate list for a framework service:","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Auth/Internal/ContainerResolver.zep#L109-L145","documentation":"On the legacy Di branch of ContainerResolver::resolveFresh(), a name that is neither registered in the DI nor an existing (autoloadable) class cannot be built fresh, so a ContainerException is thrown. The Di's class builder can construct unregistered classes, but only when class_exists($name) is true - a typo or a missing import makes both checks fail.","triggerScenarios":"resolveFresh($di, 'Phalcon\\Auth\\Adapter\\Streem') with a misspelled class name; resolving a guard/adapter name that was never $di->set() and whose class does not exist (not autoloaded, wrong namespace, missing use statement).","commonSituations":"Typo in a class-string taken from config; class moved or renamed between versions so autoloading fails; config referencing a class in a namespace that was never imported/rewritten during an upgrade.","solutions":["Fix the class name string (typo, namespace, casing) so class_exists() returns true","Or explicitly register the service in the DI: $di->set($name, $definition)","Run composer dump-autoload / verify the PSR-4 mapping if the class exists on disk but does not autoload"],"exampleFix":"// before\n$cfg = ['adapter' => ['name' => 'Phalcon\\\\Auth\\\\Adapter\\\\Streem']];\n\n// after\n$cfg = ['adapter' => ['name' => 'Phalcon\\\\Auth\\\\Adapter\\\\Stream']];","handlingStrategy":"validation","validationCode":"if (!$di->has($name) && !class_exists($name)) {\n    throw new RuntimeException(\"'{$name}' is neither registered in DI nor an existing class\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $instance = $di->get($name);\n} catch (\\Phalcon\\Container\\Exceptions\\Exception $e) {\n    if (!class_exists($name)) {\n        // class-name typo: fail loudly with a clear message\n    }\n}","preventionTips":["Source class names in config from ::class constants instead of string literals","Keep composer autoload mappings current after moving classes (composer dump-autoload)","Spell-check service/class keys in config against the definitions that register them"],"tags":["auth","dependency-injection","class-not-found","typo"],"backgroundTag":"class-not-found","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}