pear/xml_util
PEAR XML_Util provides handy helpers for working with XML: build attribute lists from arrays, generate tags, validate XML names, and more. Lightweight utility methods for creating and checking XML document parts in PHP.
pear/xml_util remains a legacy PEAR package for basic XML manipulation, now at v1.4.5, with minimal updates. Use only in legacy Laravel/PHP codebases where it’s already integrated. Install via Composer (if available via PEAR channel) or manually include class files. The primary entry point is the XML_Util class, with static methods like buildXmlDocument() or sortAttributes(). Your first use case is likely generating or cleaning XML in outdated systems—e.g., converting arrays to XML for legacy APIs or ETL processes.
New in v1.4.5: Fixed a bug where buildXmlDocument() could throw an error when processing arrays with integer keys (e.g., ["0" => "value"]). This resolves crashes when numeric keys are used directly (previously required workarounds like wrapping keys in strings).
XML_Util::buildXmlDocument() to serialize arrays into XML, now safer for arrays with integer keys (e.g., ["0" => "item"]).XML_Util::sortAttributes() to normalize XML output for testing or diffing.XML_Util::checkXMLValid() to verify XML strings before processing.HTTP_Request2), xml_util fits naturally—avoid introducing it into modern Laravel codebases.Updated Workflow:
["0" => "value"] to ["item_0" => "value"]—the package now handles it natively.buildXmlDocument() fails, check for non-array inputs or mixed key types (e.g., ["key" => ["0" => "value"]]).@attributes for custom attributes).UTF-8 to methods to avoid mojibake.DOMDocument or Symfony\Component\Serializer for new projects.include_path or PEAR repository config. Verify path in vendor/pear-xml_util.["0" => "value"]) is resolved, but edge cases like ["" => "value"] (empty string keys) may still cause issues.How can I help you explore Laravel packages today?