saloonphp/xml-wrangler
XML Wrangler is a lightweight SaloonPHP plugin for working with XML in HTTP requests and responses. Easily build XML bodies, set the right headers, and parse XML responses into usable data for your Laravel or PHP API integrations.
Strengths:
SimpleXMLElement or DOMDocument. This aligns well with Laravel’s emphasis on developer productivity.Query<T>) to catch parsing errors at compile time, improving reliability over dynamic approaches like json_decode().$response = Saloon::call(SoapClient::class)->response();
$data = XmlReader::fromResponse($response)->query('//Envelope/Body')->all();
Weaknesses:
spatie/laravel-activitylog, it doesn’t integrate with Laravel’s caching, queues, or event systems. For example, parsing large XML files would require manual chunking or streaming logic.XmlException) may not integrate smoothly with Laravel’s error handling (e.g., App\Exceptions\Handler), requiring additional wrapper logic.Laravel Compatibility:
XmlReaderInterface) for dependency injection.Response objects via XmlReader::fromResponse(), enabling zero-boilerplate XML parsing in HTTP clients.Http::macro() for global XML parsing/writing:
Http::macro('parseXml', function ($response) {
return XmlReader::fromResponse($response)->all();
});
file_get_contents() + XmlReader::fromString()), unlike Laravel’s Eloquent or filesystem helpers.Stack Fit:
veezee/xml).Low Risk:
Medium Risk:
saloonphp/saloon@^4.0 could force Saloon upgrades, introducing breaking changes.High Risk:
Use Case Validation:
Performance Needs:
Integration Depth:
SimpleXMLElement, DOMDocument) that could be deprecated?Error Handling:
Long-Term Viability:
ext-simplexml, xmlwriter) if XML Wrangler becomes unsupported?Laravel Alignment:
$this->app->singleton(XmlReader::class, function ($app) {
return new XmlReader();
});
XmlReader::fromResponse() in Saloon clients:
public function response(): XmlResponse
{
return new XmlResponse(
$this->client->sendAndGetResponse($this->request)
);
}
Http facade for global XML parsing:
Http::macro('parseXml', function ($response) {
return XmlReader::fromResponse($response)->all();
});
PHP Ecosystem:
veezee/xml, reducing bloat.SimpleXMLElement).XmlReader in HTTP clients.XmlWriter for outgoing XML requests (e.g., SOAP).xml extension (enabled by default in PHP).v1.x) are backward-compatible.saloonphp/saloon releases).saloonphp/xml-wrangler to composer.json.AppServiceProvider:
$this->app->bind(XmlReader::class, function () {
return new XmlReader();
});
How can I help you explore Laravel packages today?