metabytes-sro/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML and a few others.
18,068
Install
composer require metabytes-sro/laravel-formatter
Latest Version:3.6.2
PHP:^8.2
License:MIT
Last Updated:Sep 13, 2024
Links: GitHub  ·  Packagist
Maintainer: Metabytes s.r.o.

Laravel Formatter

Table of Contents

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.

Works with Laravel 6.x, 7.x, 8.x

Based on Soapbox/laravel-formatter, ejetar/laravel-formatter

Installation

Through command line:

composer require metabytes-sro/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

use MetabytesSRO\Formatter\Formatter;

Supported Types

Formatter::JSON; //json
Formatter::CSV;  //csv
Formatter::XML;  //xml
Formatter::ARR;  //array
Formatter::YAML; //yaml

Making Your First Formatter(s)

$formatter = Formatter::make($jsonString, Formatter::JSON);
$formatter = Formatter::make($yamlString, Formatter::YAML);
$formatter = Formatter::make($array, Formatter::ARR);
...

Outputting From Your Formatter

$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.

Related Packages

izzy-p/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML...

28 0
soapbox/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML...

1,100,290 247
daniel-furmanov/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML...

27,345 4
hitsend/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML...

1,971 247
nmfmcosta/laravel-formatter

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML...

20,297 1