phar-io/manifest · error · ManifestDocumentException

File " " not found

Error message

File "%s" not found

What it means

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.

Solutions

  1. Verify the path with is_file() / realpath() before calling fromFile()
  2. Use an absolute path resolved from __DIR__ or a configured base directory
  3. When loading from a phar, use the full phar:// stream path and confirm the file exists inside the archive

Example fix

// before
$doc = ManifestDocument::fromFile('manifest.xml');
// after
$path = __DIR__ . '/manifest.xml';
if (!is_file($path)) {
    throw new RuntimeException("manifest.xml missing at $path");
}
$doc = ManifestDocument::fromFile($path);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!is_file($filename)) {
    throw new RuntimeException(sprintf('Manifest file "%s" not found', $filename));
}

Type guard

function manifestPathExists(string $filename): bool { return is_file($filename); }

Try / catch

try {
    $document = ManifestDocument::fromFile($filename);
} catch (ManifestDocumentException $e) {
    if (str_contains($e->getMessage(), 'not found')) {
        // correct the path or abort with a clear user-facing message
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: Running from a different working directory than assumed; manifests referenced inside .phar archives with wrong stream paths; case-sensitive filesystem mismatches.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of phar-io/manifest@c581d4941e (2026-09-14). Data as JSON: /api/errors/7df772d85e87fca3. Report an issue: GitHub.

Appendix: source

Thrown at src/xml/ManifestDocument.php:32

use DOMElement;
use Throwable;
use function count;
use function file_get_contents;
use function is_file;
use function libxml_clear_errors;
use function libxml_get_errors;
use function libxml_use_internal_errors;
use function sprintf;

class ManifestDocument {
    public const XMLNS = 'https://phar.io/xml/manifest/1.0';

    /** @var DOMDocument */
    private $dom;

    public static function fromFile(string $filename): ManifestDocument {
        if (!is_file($filename)) {
            throw new ManifestDocumentException(
                sprintf('File "%s" not found', $filename)
            );
        }

        return self::fromString(
            file_get_contents($filename)
        );
    }

    public static function fromString(string $xmlString): ManifestDocument {
        $prev = libxml_use_internal_errors(true);
        libxml_clear_errors();

        try {
            $dom = new DOMDocument();
            $dom->loadXML($xmlString);
            $errors = libxml_get_errors();
            libxml_use_internal_errors($prev);

View on GitHub (pinned to c581d4941e)