{"record":{"id":"36297360098a5562","repo":"phalcon/cphalcon","slug":"the-collection-name-does-not-exist-in-the-mana","errorCode":null,"errorMessage":"The collection '{name}' does not exist in the manager","messagePattern":"The collection '(.+?)' does not exist in the manager","errorType":"exception","errorClass":"Phalcon\\Assets\\Exceptions\\CollectionNotFound","httpStatus":null,"severity":"error","filePath":"phalcon/Assets/Manager.zep","lineNumber":299,"sourceCode":"        return this->has(name);\n    }\n\n    /**\n     * Returns a collection by its id.\n     *\n     * ```php\n     * $scripts = $assets->get(\"js\");\n     * ```\n     *\n     * @param string $name\n     *\n     * @return Collection\n     * @throws Exception\n     */\n    public function get( string name) -> <Collection>\n    {\n        if unlikely true !== isset(this->collections[name]) {\n            throw new CollectionNotFound(name);\n        }\n\n        return this->collections[name];\n    }\n\n    /**\n     * Returns existing collections in the manager\n     *\n     * @return Collection[]\n     */\n    public function getCollections() -> <Collection[]>\n    {\n        return this->collections;\n    }\n\n    /**\n     * Returns the CSS collection of assets\n     *","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Assets/Manager.zep#L281-L317","documentation":"Phalcon\\Assets\\Manager::get(name) returns a named collection previously created in the manager. Collections live in an in-memory map per Manager instance; if the name is not a key in that map the manager throws CollectionNotFound instead of returning null.","triggerScenarios":"`$assets->get('js')` before any `$assets->create('js', ...)` / `$assets->collection('js')->add(...)`; a typo or case mismatch in the name; calling get() on a fresh Manager instance (DI service configured as shared=false or re-instantiated) after the collection was registered on a different instance.","commonSituations":"Collections registered in a bootstrap/provider that did not run for the current module; DI definition accidentally non-shared so each injection gets an empty Manager; name drift between template ('footerJs') and provider ('footer-js').","solutions":["Create the collection before retrieving it: `$assets->collection('js')->addJs('js/app.js')` or `$assets->create(...)`","Guard with the built-in check: `if ($assets->has('js')) { ... }`","List what actually exists: `print_r(array_keys($assets->getCollections()))`","Make sure the 'assets' DI service is shared so all code sees the same Manager instance"],"exampleFix":"// before\n$collection = $assets->get('footerJs'); // CollectionNotFound\n// after\n$assets->collection('footerJs')->addJs('js/footer.js', true, false);\n$collection = $assets->get('footerJs');","handlingStrategy":"validation","validationCode":"if ($assets->has('js')) {\n    $collection = $assets->get('js');\n} else {\n    $collection = $assets->collection('js'); // create on first use\n}","typeGuard":null,"tryCatchPattern":"try {\n    $collection = $assets->get('footerJs');\n} catch (\\Phalcon\\Assets\\Exceptions\\CollectionNotFound $e) {\n    $collection = $assets->collection('footerJs'); // lazy-create then populate\n}","preventionTips":["Use Manager::has(name) before get(name) for optional collections","Define collection names as constants shared between providers and templates","Register the 'assets' DI service as shared so collection state survives injections"],"tags":["assets","collection","not-found","di-services"],"backgroundTag":"lookup-key-not-found","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}