Add the method xml integrating the laravel's response, converting eloquent return to XML.
jailtonsc/laravel-response-xml is a Laravel package for add the method xml integrating the laravel's response, converting eloquent return to xml..
It currently has 47 GitHub stars and 287.519 downloads on Packagist (latest version v3.0.1).
Install it with composer require jailtonsc/laravel-response-xml.
Discover more Laravel packages by jailtonsc
or browse all Laravel packages to compare alternatives.
Last updated
Add the method "xml" integrating the laravel's response, converting eloquent return to XML.
composer require jailtonsc/laravel-response-xml
Add in config/app.php in place providers
XmlResponse\XmlResponseServiceProvider::class
Add in config/app.php in place aliases
'Xml' => XmlResponse\Facades\XmlFacade::class
php artisan vendor:publish
Route::get('/', function () {
return response()->xml(User::all());
});
With status code
Route::get('/', function () {
return response()->xml(User::all(), 404);
});
Setting by code
$config = [
'template' => '<test></test>',
'rowName' => 'name'
];
Route::get('/', function () {
return response()->xml(User::all(), 200, $config);
});
Return string xml
$xml = Xml::asXml(User::all());
Or
$config = [
'template' => '<test></test>',
'rowName' => 'name'
];
$xml = Xml::asXml(User::all(), $config);
file config/xml.php
template: xml template.
caseSensitive: case sensitive xml tag.
showEmptyField: Show empty field.
charset: encoding.
rowName: line name if it is an array.
The Laravel Response XML is open-sourced software licensed under the MIT license