lukaserat / webmozart-json-laravel by lukaserat

A webmozart/json service provider for Laravel
8
0
0
Package Data
Maintainer Username: lukaserat
Maintainer Contact: dev.lukaserat@gmail.com (Lukaserat Jonjonvi)
Package Create Date: 2015-06-14
Package Last Update: 2015-06-14
Language: PHP
License: MIT
Last Refreshed: 2024-04-30 15:03:14
Package Statistics
Total Downloads: 8
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 0
Total Forks: 0
Total Open Issues: 0

Webmozart JSON Laravel

A webmozart/json wrapper for Laravel Framework.

Installation

Use [Composer] to install the package:

$ composer require lukaserat/webmozart-json-laravel

Laravel Users

I just combined the two major classes webmozart/json has to offer, the Encoder and Decoder, for easy usage.

Just include the service provider and that's it.

// app/config/app.php
'providers' => [
    '...',
    'Lukaserat\WebmozartJson\JsonServiceProvider'
];

Note: Facade will be automatically registered as 'JsonHelper'

When this provider is booted, you'll gain access on helpful functions from webmozart/json. See the example below:

Encoding

Instead of this...

// somewhere in your application..
use Webmozart\Json\JsonEncoder;
$encoder = new JsonEncoder();

// Store JSON in string
$string = $encoder->encode($data);

// Store JSON in file
$encoder->encodeFile($data, '/path/to/file.json');

You can do it this way..

// Store JSON in string
$string = JsonHelper::encode($data);

// Store JSON in file
JsonHelper::encodeFile($data, '/path/to/file.json');

Webmozart/Json Usage

This is just a wrapper for Laravel. For more details about the webmozart/json go to its github page.