PHPackages                             mgbg/laravel-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mgbg/laravel-formatter

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

mgbg/laravel-formatter
======================

A formatting library that converts data output between XML, CSV, JSON, TXT, YAML and a few others.

06PHP

Since Apr 4Pushed 3y agoCompare

[ Source](https://github.com/mgbg/laravel-formatter)[ Packagist](https://packagist.org/packages/mgbg/laravel-formatter)[ RSS](/packages/mgbg-laravel-formatter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Changelog
=========

[](#changelog)

- Update support for Laravel 6 &amp; phpunit 8
- Update composer.json
- Upgrade to PSR-4
- add parameter newline, delimiter, enclosure, and escape to export csv
- When converting a XML to an array, convert @attributes to *attribute*
- add parameter encoding and formated to export xml
- JSON parse fix (Instead of only converting the first level to array, use the associative array parameter with true, so all levels will be decoded to array structure)
- Add support for laravel 5
- add package discovery for laravel 5
- add support delimiter to a csv

Formatter Bundle
================

[](#formatter-bundle)

[![Build Status](https://camo.githubusercontent.com/0cadc69168427771770566400eb3d7f6e72f5bd5839b86a0199d7d65fae584b7/68747470733a2f2f7472617669732d63692e6f72672f536f6170426f782f6c61726176656c2d666f726d61747465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SoapBox/laravel-formatter)

A formatter package that will help you to easily convert between various formats such as XML, JSON, CSV, etc...

Goals
=====

[](#goals)

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.

Installation
============

[](#installation)

Through command line:

```
composer require soapbox/laravel-formatter
```

Through composer.json:

```
{
  "require": {
    "soapbox/laravel-formatter": "2.x"
  }
}
```

Parsers
-------

[](#parsers)

All of the following are supported formats that the formatter can read from.

- Array
- CSV
- JSON
- XML
- YAML

Formats
-------

[](#formats)

All of the following are formats that are supported for output.

- Array
- CSV
- JSON
- XML
- YAML

General Usage
-------------

[](#general-usage)

**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();
```

Deprecated Functionality
------------------------

[](#deprecated-functionality)

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());
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2e5f4545d09f665988e784a0b7fce404b6e72ea70e1a3d87e9a7b0fc01c024f?d=identicon)[AiAe](/maintainers/AiAe)

---

Top Contributors

[![Jaspaul](https://avatars.githubusercontent.com/u/2836589?v=4)](https://github.com/Jaspaul "Jaspaul (45 commits)")[![grahammccarthy](https://avatars.githubusercontent.com/u/1336930?v=4)](https://github.com/grahammccarthy "grahammccarthy (19 commits)")[![dberry37388](https://avatars.githubusercontent.com/u/1000887?v=4)](https://github.com/dberry37388 "dberry37388 (9 commits)")[![vicgonvt](https://avatars.githubusercontent.com/u/7350307?v=4)](https://github.com/vicgonvt "vicgonvt (3 commits)")[![drolean](https://avatars.githubusercontent.com/u/810731?v=4)](https://github.com/drolean "drolean (3 commits)")[![dyanakiev](https://avatars.githubusercontent.com/u/11967079?v=4)](https://github.com/dyanakiev "dyanakiev (2 commits)")[![worzy](https://avatars.githubusercontent.com/u/1092417?v=4)](https://github.com/worzy "worzy (1 commits)")[![cecilozaur](https://avatars.githubusercontent.com/u/853395?v=4)](https://github.com/cecilozaur "cecilozaur (1 commits)")[![dpwilhelmsen](https://avatars.githubusercontent.com/u/1758049?v=4)](https://github.com/dpwilhelmsen "dpwilhelmsen (1 commits)")[![garethtdavies](https://avatars.githubusercontent.com/u/135382?v=4)](https://github.com/garethtdavies "garethtdavies (1 commits)")[![AustinW](https://avatars.githubusercontent.com/u/333398?v=4)](https://github.com/AustinW "AustinW (1 commits)")

### Embed Badge

![Health badge](/badges/mgbg-laravel-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/mgbg-laravel-formatter/health.svg)](https://phpackages.com/packages/mgbg-laravel-formatter)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
