2017 © Pedro Peláez
 

library laravel-parser

Simple Format Parser For Laravel 4

image

nathanmac/laravel-parser

Simple Format Parser For Laravel 4

  • Saturday, November 8, 2014
  • by nathanmac
  • Repository
  • 3 Watchers
  • 14 Stars
  • 365 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

laravel-parser

Build Status Still Maintained, (*1)

Project no longer maintained see the Parser project for a replacement., (*2)

Simple Format Parser For Laravel 4, (*3)

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require Nathanmac/laravel-parser., (*4)

"require": {
    "nathanmac/laravel-parser": "dev-master"
}

Next, update Composer from the Terminal:, (*5)

composer update

Once this operation completes, the final step is to add the service provider. Open app/config/app.php, and add a new item to the providers array., (*6)

'Nathanmac\Parser\ParserServiceProvider'
Parsing Functions
    Parse::json($payload);      // JSON > Array
    Parse::xml($payload);       // XML > Array
    Parse::yaml($payload);      // YAML > Array
    Parse::querystr($payload);  // Query String > Array
    Parse::serialize($payload); // Serialized Object > Array
Parse Input/Payload (PUT/POST)
    Parse::payload();       // Auto Detect Type - 'Content Type' HTTP Header
    Parse::payload('application/json'); // Specifiy the content type
Parse JSON
$parsed = Parse::json('
    {
        "message": {
            "to": "Jack Smith",
            "from": "Jane Doe",
            "subject": "Hello World",
            "body": "Hello, whats going on..."
        }
    }');
Parse XML
$parsed = Parse::xml('
            <?xml version="1.0" encoding="UTF-8"?>
            <xml>
                <message>
                    <to>Jack Smith</to>
                    <from>Jane Doe</from>
                    <subject>Hello World</subject>
                    <body>Hello, whats going on...</body>
                </message>
            </xml>');
Parse Query String
$parsed = Parse::querystr('to=Jack Smith&from=Jane Doe&subject=Hello World&body=Hello, whats going on...');
Parse Serialized Object
$parsed = Parse::serialize('a:1:{s:7:"message";a:4:{s:2:"to";s:10:"Jack Smith";s:4:"from";s:8:"Jane Doe";s:7:"subject";s:11:"Hello World";s:4:"body";s:24:"Hello, whats going on...";}}');
Parse YAML
$parsed = Parse::yaml('
                ---
                message: 
                    to: "Jack Smith"
                    from: "Jane Doe"
                    subject: "Hello World"
                    body: "Hello, whats going on..."
                ');
Supported Content-Types
XML
---
application/xml > XML
text/xml > XML

JSON
----
application/json > JSON
application/x-javascript > JSON
text/javascript > JSON
text/x-javascript > JSON
text/x-json > JSON

YAML
----
text/yaml > YAML
text/x-yaml > YAML
application/yaml > YAML
application/x-yaml > YAML

MISC
----
application/vnd.php.serialized > Serialized Object
application/x-www-form-urlencoded' > Query String

The Versions

08/11 2014

dev-master

9999999-dev

Simple Format Parser For Laravel 4

  Sources   Download

MIT

The Requires

 

by Avatar nathanmac

23/04 2014

v1.0

1.0.0.0

Simple Format Parser For Laravel 4

  Sources   Download

MIT

The Requires

 

by Avatar nathanmac