Package Data | |
---|---|
Maintainer Username: | grahammccarthy |
Maintainer Contact: | graham@soapboxhq.com (Graham McCarthy) |
Package Create Date: | 2013-06-28 |
Package Last Update: | 2020-03-23 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:09:46 |
Package Statistics | |
---|---|
Total Downloads: | 967,826 |
Monthly Downloads: | 4,766 |
Daily Downloads: | 209 |
Total Stars: | 251 |
Total Watchers: | 22 |
Total Forks: | 95 |
Total Open Issues: | 14 |
A formatter package that will help you to easily convert between various formats such as XML, JSON, CSV, etc...
The goals of this library are to allow the transfomation of data formats from one type to another. See Parsers and Formats to see supported input / output formats.
Through command line:
composer require soapbox/laravel-formatter
Through composer.json:
{
"require": {
"soapbox/laravel-formatter": "2.x"
}
}
All of the following are supported formats that the formatter can read from.
All of the following are formats that are supported for output.
Including The Formatter
use SoapBox\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();
The following have been deprecated from the library, however you can easily continue using them in your application
Serialized Array
$serialized = serialize($formatter->toArray());
PHP Export
$export = var_export($formatter->toArray());