All Projects → Tucker-Eric → laravel-xml-middleware

Tucker-Eric / laravel-xml-middleware

Licence: MIT License
A Laravel Middleware to accept XML requests

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to laravel-xml-middleware

VBA-IDE-Code-Export
Export & Import VBA code for use with Git (or any VCS)
Stars: ✭ 89 (+423.53%)
Mutual labels:  xml
pyEDAA.IPXACT
An IP-XACT DOM for IEEE 1685-2014 in Python.
Stars: ✭ 13 (-23.53%)
Mutual labels:  xml
libcitygml
C++ Library for CityGML Parsing and Visualization
Stars: ✭ 69 (+305.88%)
Mutual labels:  xml
json2xml
json to xml converter in python3
Stars: ✭ 76 (+347.06%)
Mutual labels:  xml
spec
Just Data. Save up to 85% network bandwidth and storage.
Stars: ✭ 86 (+405.88%)
Mutual labels:  xml
video seg
视频片段提取
Stars: ✭ 14 (-17.65%)
Mutual labels:  xml
InshortApp
Demo app like inshort
Stars: ✭ 28 (+64.71%)
Mutual labels:  xml
SNAP
Easy data format saving and loading for GameMaker Studio 2.3.2
Stars: ✭ 49 (+188.24%)
Mutual labels:  xml
vxquery
Mirror of Apache VXQuery
Stars: ✭ 19 (+11.76%)
Mutual labels:  xml
vscode-odoo-snippets
Develop Odoo modules faster and with no Typing Errors.
Stars: ✭ 20 (+17.65%)
Mutual labels:  xml
Fore
Fore - declarative programming with web components
Stars: ✭ 34 (+100%)
Mutual labels:  xml
web-mode-edit-element
Helper-functions for attribute- and element-handling
Stars: ✭ 18 (+5.88%)
Mutual labels:  xml
datamaker
Data generator command-line tool and library. Create JSON, CSV, XML data from templates.
Stars: ✭ 23 (+35.29%)
Mutual labels:  xml
fox
A Fortran XML library
Stars: ✭ 51 (+200%)
Mutual labels:  xml
synapse
Apache Synapse is a lightweight and high-performance Enterprise Service Bus (ESB)
Stars: ✭ 43 (+152.94%)
Mutual labels:  xml
advxml
A lightweight, simple and functional library DSL to work with XML in Scala with Cats
Stars: ✭ 54 (+217.65%)
Mutual labels:  xml
sitewriter
A rust library to generate sitemaps.
Stars: ✭ 18 (+5.88%)
Mutual labels:  xml
XPathTools
A Visual Studio Extension which can run any XPath and XPath function; navigates through results at the click of a button. Can show and copy any XPath incl. XML namespaces, avoiding XML namespace induced headaches. Keeps track of the current XPath via the statusbar.
Stars: ✭ 40 (+135.29%)
Mutual labels:  xml
config-loader
Simple C++ Config Loader Framework(Serialization & Reflection)
Stars: ✭ 87 (+411.76%)
Mutual labels:  xml
laravel-browser-filter
Laravel middleware to filter routes based on browser types & versions.
Stars: ✭ 20 (+17.65%)
Mutual labels:  laravel-middleware

laravel-xml-middleware

Latest Stable Version Total Downloads License Build Status

A Laravel Middleware to accept XML requests

Configuration

Install Through Composer

composer require tucker-eric/laravel-xml-middleware

Register The Service Provider

In config/app.php add the service provider to the providers array:

    'providers' => [
        //Other Service Providers
        XmlMiddleware\XmlRequestServiceProvider::class,
    ];

Register the middleware

In app/Http/Kernel.php

    protected $routeMiddleware = [
            /// Other Middleware
            'xml' => \XmlMiddleware\XmlRequestMiddleware::class,
        ];

Applying the middleware to routes

Add the middleware to your route as desired

Controller Middleware

class MyController extends Controller
{
    public function __construct()
    {
        $this->middleware('xml');
    }
}

Route Middleware

    Route::group(['middleware' => 'xml'], function() {
        Route::post('my-api-endpoint', 'MyOtherController@store');
    });
        Route::post('my-api-endpoint', 'MyOtherController@store')->middleware('xml');

Accessing XML Input With Middleware

If you are using the middleware it will automatically inject the xml into the request as an array and you you can access the xml data in your controller with the $request->all():

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class MyController extends Controller
{
    public function __construct()
    {
        $this->middleware('xml');
    }
    
    public function store(Request $request)
    {
        $request->all();
    }
}

Accessing XML Input

To access the xml input without the middleware use the xml() method on the Request:

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

Class MyOtherController extends Controller
{
    public function store(Request $request)
    {
        $xml = $request->xml();
    }
}

To access the xml request as an object pass false to the xml() method:

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

Class MyOtherController extends Controller
{
    public function store(Request $request)
    {
        $xml = $request->xml(false);
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].