phar-io/manifest · error · ManifestLoaderException
Processing string failed
Error message
Processing string failed
What it means
ManifestLoader::fromString() maps a manifest supplied as an XML string and wraps any Exception (XML parse failure or mapping failure) into ManifestLoaderException with the fixed message 'Processing string failed'. The original exception is chained as previous, so details are only visible there.
Solutions
- Inspect $e->getPrevious()->getMessage() for the actual XML or mapping error
- Validate the XML string with a parser or schema check before handing it to fromString()
- Log the input string (or write it to a temp file) when the failure occurs to spot corruption
Example fix
// before
catch (ManifestLoaderException $e) { echo $e->getMessage(); } // 'Processing string failed'
// after
catch (ManifestLoaderException $e) {
echo $e->getMessage();
if ($e->getPrevious()) echo ": " . $e->getPrevious()->getMessage();
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the string is well-formed XML first
$dom = new DOMDocument();
if (!$dom->loadXML($manifestString)) {
throw new InvalidArgumentException('Manifest string is not valid XML');
} Try / catch
try {
$manifest = ManifestLoader::fromString($xml);
} catch (ManifestLoaderException $e) {
$cause = $e->getPrevious(); // holds XML or mapping error details
} Prevention
- Validate XML well-formedness before passing to fromString()
- Never rely on 'Processing string failed' alone — read the chained exception
- Trim BOM/whitespace from strings sourced from files or APIs
When it happens
Trigger: fromString() with malformed XML, an empty string, valid XML that fails schema expectations, or content that fails mapping (unsupported type, bad version constraints).
Common situations: Manifests fetched from an API or embedded in another file; unit tests feeding invalid XML to verify error behavior; truncated strings.
Related errors
- $e->getMessage()
- Unsupported type
- Unsupported version constraint
- Loading failed.
- InvalidApplicationNameException::InvalidFormat
AI-assisted analysis of phar-io/manifest@c581d4941e (2026-09-14).
Data as JSON: /api/errors/b74d15f771391534.
Report an issue: GitHub.
Appendix: source
Thrown at src/ManifestLoader.php:40
throw new ManifestLoaderException(
sprintf('Loading %s failed.', $filename),
(int)$e->getCode(),
$e
);
}
}
public static function fromPhar(string $filename): Manifest {
return self::fromFile('phar://' . $filename . '/manifest.xml');
}
public static function fromString(string $manifest): Manifest {
try {
return (new ManifestDocumentMapper())->map(
ManifestDocument::fromString($manifest)
);
} catch (Exception $e) {
throw new ManifestLoaderException(
'Processing string failed',
(int)$e->getCode(),
$e
);
}
}
}
View on GitHub (pinned to c581d4941e)