Package Data | |
---|---|
Maintainer Username: | jailtonsc |
Package Create Date: | 2016-08-20 |
Package Last Update: | 2018-06-30 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-20 03:01:47 |
Package Statistics | |
---|---|
Total Downloads: | 207,944 |
Monthly Downloads: | 2,585 |
Daily Downloads: | 104 |
Total Stars: | 46 |
Total Watchers: | 3 |
Total Forks: | 15 |
Total Open Issues: | 10 |
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