soapbox/laravel-formatter
Composer 安装命令:
composer require soapbox/laravel-formatter
包简介
A formatting library that converts data output between XML, CSV, JSON, TXT, YAML and a few others.
README 文档
README
- Update support for Laravel 6 & 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
A formatter package that will help you to easily convert between various formats such as XML, JSON, CSV, etc...
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
Through command line:
composer require soapbox/laravel-formatter
Through composer.json:
{
"require": {
"soapbox/laravel-formatter": "2.x"
}
}
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 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
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());
soapbox/laravel-formatter 适用场景与选型建议
soapbox/laravel-formatter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.08M 次下载、GitHub Stars 达 249, 最近一次更新时间为 2014 年 01 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「yaml」 「xml」 「data」 「csv」 「convert」 「formatter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 soapbox/laravel-formatter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 soapbox/laravel-formatter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 soapbox/laravel-formatter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
Load DOM document safety
Data provider for yii2
SUML for PHP
统计信息
- 总下载量: 1.08M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 259
- 点击次数: 28
- 依赖项目数: 19
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-01-07