manojkiran / jsonwriter
Reads and Writes PHP array or Laravel Collection to JSON file
dev-master
2019-07-03 06:55 UTC
Requires
- php: ^7.1
- illuminate/support: 5.7.*|5.8.*
Requires (Dev)
- orchestra/testbench: 3.8.*
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-10-29 05:34:47 UTC
README
Read and write PHP array| Laravel Collection | EloquentCollection to json file
Installation
You can install the package via composer:
composer require manojkiran/jsonwriter
Import
use Manojkiran\JsonWriter\Facades\JsonWriter;
Usage
Writing
Writing the Content to Json
//get the List of Active users $usersList = User::where('status','=','Active')->get(); //getting the path where the file is available $jsonFilePath = storage_path('jsonWriter.json'); //loading the Json File and Writing the Content to it $writeToJson = JsonWriter::load( $jsonFilePath) ->write($usersList);
Writing the Content to Json(Force)
//by default the duplicate Content Will Not to Writtent To Json File(To Reduce the data Size) //array of the Projects by Taylor Otwell $laravel = ['name' => 'Taylor Otwell','developed' => ['Laravel','Lumen','Telescope','Nova']]; //getting the path where the file is available $jsonFilePath = storage_path('jsonWriter.json'); //loading the Json File and Writing the Content to it $writeToJson = JsonWriter::load( $jsonFilePath) ->write($laravel,true);
Reading
//get the List of Active users $usersList = User::where('status','=','Active')->get(); //getting the path where the file is available $jsonFilePath = storage_path('jsonWriter.json'); //loading the Json File and Writing the Content to it $writeToJson = JsonWriter::load( $jsonFilePath) ->parseFile();
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email manojkiran10031998@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.