https://github.com/ejetar/laravel-formatter
A package that enables you to convert your data into various formats such as JSON, XML, CSV and YAML. Based on FuelPHP's 💧 formatter class.
https://github.com/ejetar/laravel-formatter
conversion convert csv data format formatter json laravel output php response xml yaml
Last synced: 24 days ago
JSON representation
A package that enables you to convert your data into various formats such as JSON, XML, CSV and YAML. Based on FuelPHP's 💧 formatter class.
- Host: GitHub
- URL: https://github.com/ejetar/laravel-formatter
- Owner: ejetar
- Archived: true
- Fork: true (Soapbox/laravel-formatter)
- Created: 2019-07-26T00:42:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T15:03:34.000Z (almost 6 years ago)
- Last Synced: 2025-05-26T23:48:29.450Z (9 months ago)
- Topics: conversion, convert, csv, data, format, formatter, json, laravel, output, php, response, xml, yaml
- Language: PHP
- Homepage:
- Size: 121 KB
- Stars: 5
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Laravel Formatter
## Table of Contents
* [About](#about)
* [Installation](#installation)
* [Parsers](#parsers)
* [Formats](#formats)
* [General Usage](#general-usage)
* [Changelog](#changelog)
* [Contributing](#contributing)
* [License](#license)
## About
A package that enables you to convert your data into various formats such as JSON, XML, CSV and YAML. Based on FuelPHP's 💧 formatter class.
## Installation
Through command line:
```bash
composer require ejetar/laravel-formatter
```
## Parsers
All of the following are supported formats that the formatter can read from.
* Array
* CSV
* JSON
* XML
* YAML
## Formats
All of the following are formats that are supported for output.
* Array
* CSV
* JSON
* XML
* YAML
## General Usage
__Including The Formatter__
```php
use Ejetar\Formatter\Formatter;
```
__Supported Types__
```php
Formatter::JSON; //json
Formatter::CSV; //csv
Formatter::XML; //xml
Formatter::ARR; //array
Formatter::YAML; //yaml
```
__Making Your First Formatter(s)__
```php
$formatter = Formatter::make($jsonString, Formatter::JSON);
$formatter = Formatter::make($yamlString, Formatter::YAML);
$formatter = Formatter::make($array, Formatter::ARR);
...
```
__Outputting From Your Formatter__
```php
$csv = $formatter->toCsv();
$json = $formatter->toJson();
$xml = $formatter->toXml();
$array = $formatter->toArray();
$yaml = $formatter->toYaml();
```
## Changelog
Nothing for now...
## Contributing
Contribute to this wonderful project, it will be a pleasure to have you with us. Let's help the free software community. You are invited to incorporate new features, make corrections, report bugs, and any other form of support.
Don't forget to star in this repository! 😀
## License
This library is a open-source software licensed under the MIT license.