{"record":{"id":"7df772d85e87fca3","repo":"phar-io/manifest","slug":"file-s-not-found","errorCode":null,"errorMessage":"File \"%s\" not found","messagePattern":"File \"(.+?)\" not found","errorType":"exception","errorClass":"ManifestDocumentException","httpStatus":null,"severity":"error","filePath":"src/xml/ManifestDocument.php","lineNumber":32,"sourceCode":"use DOMElement;\nuse Throwable;\nuse function count;\nuse function file_get_contents;\nuse function is_file;\nuse function libxml_clear_errors;\nuse function libxml_get_errors;\nuse function libxml_use_internal_errors;\nuse function sprintf;\n\nclass ManifestDocument {\n    public const XMLNS = 'https://phar.io/xml/manifest/1.0';\n\n    /** @var DOMDocument */\n    private $dom;\n\n    public static function fromFile(string $filename): ManifestDocument {\n        if (!is_file($filename)) {\n            throw new ManifestDocumentException(\n                sprintf('File \"%s\" not found', $filename)\n            );\n        }\n\n        return self::fromString(\n            file_get_contents($filename)\n        );\n    }\n\n    public static function fromString(string $xmlString): ManifestDocument {\n        $prev = libxml_use_internal_errors(true);\n        libxml_clear_errors();\n\n        try {\n            $dom = new DOMDocument();\n            $dom->loadXML($xmlString);\n            $errors = libxml_get_errors();\n            libxml_use_internal_errors($prev);","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/phar-io/manifest/blob/c581d4941e196459bf76c945a8ca922963a66708/src/xml/ManifestDocument.php#L14-L50","documentation":"ManifestDocument::fromFile() checks is_file() on the given filename and throws ManifestDocumentException 'File \"%s\" not found' if it is not an existing regular file. This is the lowest-level guard before the file is read and parsed.","triggerScenarios":"fromFile('manifest.xml') with a typo'd or relative path, a deleted/moved file, a directory path, or a phar-internal path where is_file() cannot stat the target.","commonSituations":"Running from a different working directory than assumed; manifests referenced inside .phar archives with wrong stream paths; case-sensitive filesystem mismatches.","solutions":["Verify the path with is_file() / realpath() before calling fromFile()","Use an absolute path resolved from __DIR__ or a configured base directory","When loading from a phar, use the full phar:// stream path and confirm the file exists inside the archive"],"exampleFix":"// before\n$doc = ManifestDocument::fromFile('manifest.xml');\n// after\n$path = __DIR__ . '/manifest.xml';\nif (!is_file($path)) {\n    throw new RuntimeException(\"manifest.xml missing at $path\");\n}\n$doc = ManifestDocument::fromFile($path);","handlingStrategy":"type-guard","validationCode":"if (!is_file($filename)) {\n    throw new RuntimeException(sprintf('Manifest file \"%s\" not found', $filename));\n}","typeGuard":"function manifestPathExists(string $filename): bool { return is_file($filename); }","tryCatchPattern":"try {\n    $document = ManifestDocument::fromFile($filename);\n} catch (ManifestDocumentException $e) {\n    if (str_contains($e->getMessage(), 'not found')) {\n        // correct the path or abort with a clear user-facing message\n    }\n}","preventionTips":["Build absolute paths with realpath()/__DIR__","Check is_file() before any fromFile() call","For phar-embedded manifests, verify existence inside the archive with file_exists('phar://...')"],"tags":["php","file-not-found","manifest","path"],"backgroundTag":"file-not-found","analyzedSha":"c581d4941e196459bf76c945a8ca922963a66708","analyzedAt":"2026-09-14T11:08:47.165Z","contentChangedAt":"2026-09-14T11:08:47.165Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}