- How do I install XML Wrangler in a Laravel project?
- Install it with Composer using composer require saloonphp/xml-wrangler. There is no service provider to register and no configuration file to publish for the core read and write paths, so you can start calling the reader and builder immediately. It needs no PHP extensions beyond what the DOM extension already requires, and it works inside any Laravel app as well as plain PHP services.
- Does XML Wrangler support Laravel 10, 11 and 12?
- XML Wrangler is framework-agnostic and does not hard-depend on Laravel, so Laravel version compatibility is driven by your PHP version rather than the framework release. The practical floor is PHP 8.3, with PHP 8.4 and 8.5 support landing in the 1.4.x line. It follows Laravel-shaped idioms but is equally usable in a standalone PHP script or job class.
- How do I read XML attributes, namespaces and nested elements with XML Wrangler?
- The package exposes a fluent, XPath-flavoured reader where you select elements with simple dot notation and then extract values, attributes, or lists of repeated nodes. Namespaces, attributes, and nested elements are handled predictably, so you avoid writing manual SimpleXMLElement traversal code. Results come back as clean typed values, which makes mapping into DTOs or arrays straightforward.
- How do I convert an XML response into an array or JSON in PHP?
- XML Wrangler can turn a document into a clean array or JSON-like structure, which is handy for logging, debugging, and feeding simple payloads into your own code. Be aware that array conversion is lossy by design for edge cases such as mixed content, repeated sibling elements, comments, processing instructions, CDATA sections, and normalized namespace prefixes. If a partner contract requires round-trip fidelity, use the query and writer APIs instead of the array path.
- Is XML Wrangler a good alternative to SimpleXML or DOMDocument?
- It is best thought of as an ergonomics layer rather than a replacement for the underlying engine. XML Wrangler sits on top of veewee/xml, which itself wraps PHP's DOM extension, so you get the same parsing behaviour with a far friendlier API. Choose it when you want concise, readable XML handling and accept a thin third-party dependency in exchange.
- Is XML Wrangler safe for parsing untrusted XML payloads such as XXE attacks?
- Do not assume the library is safe by default just because the API is ergonomic. XXE, external entity resolution, and entity-expansion attacks like billion laughs depend on the underlying library's defaults plus your runtime libxml configuration. Verify entity-loading behaviour explicitly in a test against a malicious fixture before letting any partner-supplied document reach this package.
- Can XML Wrangler handle large XML documents without running out of memory?
- The package exposes Query and LazyQuery helpers, and the 1.1.1 release fixed a stream-rewind bug, which shows streaming support is real but relatively lightly exercised. Memory ceilings depend heavily on document shape and on how much of the tree you materialize. Validate against your largest realistic document in a short spike rather than extrapolating from the README.
- How does XML Wrangler integrate with Saloon connectors and responses?
- The highest-value pattern is handling XML responses returned inside Saloon responses, where the package is effectively free to adopt. Instead of traversing SimpleXMLElement by hand, you write fluent queries and map results into DTOs or arrays. Both packages come from the same team, so the ergonomics line up, but XML Wrangler remains usable without Saloon.
- Is XML Wrangler production ready and who maintains it?
- The 1.x line is stable with a clean changelog and small, scoped releases, but there is a single primary maintainer and a small contributor pool with no organizational backstop. It is MIT licensed, so the practical mitigation is a thin internal facade plus pinned versions rather than a procurement fight. Named ownership inside your team and a vendor-risk review are sensible steps in regulated environments.
- How do I write or build XML programmatically with XML Wrangler?
- The package includes a chainable builder that produces clean, well-formed XML without string concatenation or manual DOMDocument calls. You can assemble nested elements, attributes, and repeated nodes in a readable sequence, which suits API payloads, SOAP requests, and generated configuration files. For contract-bound documents, keep the writer as the source of truth rather than round-tripping through array conversion.