PHP code example of vmporcayom / laravel-xml

1. Go to this page and download the library: Download vmporcayom/laravel-xml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vmporcayom / laravel-xml example snippets


$request->xml();

$request->isXml();

$request->wantsXml();

Xml::is_valid($request->xml());

$errors = Xml::validate($request->xml(), 'path_to/sample.xsd');

if ($errors) {
    return response()->xml(['error' => $errors], 422);
}

Route::get('/users', function () {
    $users = App\User::all();
    return response()->xml(['users' => $users->toArray()]);
});

protected $routeMiddleware = [
    // ...
    'xml' => \Bmatovu\LaravelXml\Http\Middleware\RequireXml::class,
];

Route::post('/user/store', function (Request, $request) {
    // do something...
})->middleware('xml');

Xml::encode(['key' => 'value']);

xml_encode(['key' => 'value']);

Xml::decode('<?xml version="1.0" encoding="UTF-8"

xml_decode('<?xml version="1.0" encoding="UTF-8"