{"record":{"id":"eb478c992cf3b1b6","repo":"phalcon/cphalcon","slug":"asset-s-content-for-path-cannot-be-read","errorCode":null,"errorMessage":"Asset's content for '{path}' cannot be read","messagePattern":"Asset's content for '(.+?)' cannot be read","errorType":"exception","errorClass":"Phalcon\\Assets\\Exceptions\\CannotReadAsset","httpStatus":null,"severity":"error","filePath":"phalcon/Assets/Asset.zep","lineNumber":373,"sourceCode":"     * @return string\n     */\n    private function checkPath(string property) -> string\n    {\n        if (true === empty(this->{property})) {\n            return this->path;\n        }\n\n        return this->{property};\n    }\n\n    /**\n     * @param string $completePath\n     *\n     * @throws Exception\n     */\n    private function throwException(string completePath) -> void\n    {\n        throw new CannotReadAsset(completePath);\n    }\n}\n","sourceCodeStart":355,"sourceCodeEnd":376,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Assets/Asset.zep#L355-L376","documentation":"Phalcon\\Assets\\Asset reads asset files from disk through a private helper that throws CannotReadAsset when the file contents cannot be loaded. The message includes the complete path (source base path + asset path), telling you exactly which file the manager failed to read.","triggerScenarios":"Rendering or filtering an asset whose file is missing or unreadable: `$assets->outputCss()` / `outputJs()` on a collection containing the asset, or `$asset->getContent()`, when `sourceBasePath . path` does not exist or has no read permission; using a remote URL while the asset is still marked local.","commonSituations":"Wrong 'sourceBasePath' option on Assets\\Manager (e.g. pointing at the project root instead of public/); asset path typos; files not deployed or owned by another user; CDN URLs with setLocal(true) left in place.","solutions":["Reproduce the exact path from the message and check it: `ls -l <path-from-error>`","Fix the location: correct the asset's path via `setPath()`/constructor, or adjust the Manager's 'sourceBasePath' option / `$asset->setSourceBasePath()`","Give the PHP user read permission on the file","For remote assets mark them non-local: `$asset->setLocal(false)` so nothing is read from disk"],"exampleFix":"// before: manager sourceBasePath does not match the docroot\n$assets = new \\Phalcon\\Assets\\Manager(['sourceBasePath' => '/app/']);\n// after\n$assets = new \\Phalcon\\Assets\\Manager(['sourceBasePath' => '/app/public/']);","handlingStrategy":"validation","validationCode":"$source = rtrim($asset->getSourceBasePath(), '/') . '/' . ltrim($asset->getPath(), '/');\nif (!is_file($source) || !is_readable($source)) {\n    throw new RuntimeException('Asset file missing or unreadable: ' . $source);\n}\necho $assets->outputCss();","typeGuard":null,"tryCatchPattern":"try {\n    echo $assets->outputCss();\n} catch (\\Phalcon\\Assets\\Exceptions\\CannotReadAsset $e) {\n    // fall back to unfiltered <link> tags so the page still renders\n    $logger->warning($e->getMessage());\n    echo $assets->outputCss(null); // or emit raw tags for each asset path\n}","preventionTips":["Assert in CI/build that every registered asset file exists under sourceBasePath","Configure sourceBasePath from one path constant used by the whole app","Mark CDN assets setLocal(false) at registration time"],"tags":["assets","file-read","path","permissions"],"backgroundTag":"file-not-readable","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}