kristijorgji/php-json-bender
Composer 安装命令:
composer require kristijorgji/php-json-bender
包简介
A library to transform json to php array declarations.
README 文档
README
Simple library to convert json strings to php array declarations.
Table of Contents
Installation
composer require kristijorgji/php-json-bender
Example
Run in the console:
vendor/bin/phpJsonBender /srv/input/test.json /srv/output/test.php
First argument is the real path of the input json.
Second argument is the real path of the desired output.
In my example the content of the input file was as follows:
[{
"created_at": "Thu Jun 22 21:00:00 +0000 2017",
"id": 877994604561387500,
"id_str": "877994604561387520",
"text": "Creating a Grocery List Manager Using Angular, Part 1: Add & Display Items https://t.co/xFox78juL1 #Angular",
"truncated": false,
"entities": {
"hashtags": [{
"text": "Angular",
"indices": [103, 111]
}],
"symbols": [],
"user_mentions": [],
"urls": [{
"url": "https://t.co/xFox78juL1",
"expanded_url": "http://buff.ly/2sr60pf",
"display_url": "buff.ly/2sr60pf",
"indices": [79, 102]
}]
},
"source": "<a href=\"http://bufferapp.com\" rel=\"nofollow\">Buffer</a>",
"user": {
"id": 772682964,
"id_str": "772682964",
"name": "SitePoint JavaScript",
"screen_name": "SitePointJS",
"location": "Melbourne, Australia",
"description": "Keep up with JavaScript tutorials, tips, tricks and articles at SitePoint.",
"url": "http://t.co/cCH13gqeUK",
"entities": {
"url": {
"urls": [{
"url": "http://t.co/cCH13gqeUK",
"expanded_url": "http://sitepoint.com/javascript",
"display_url": "sitepoint.com/javascript",
"indices": [0, 22]
}]
},
"description": {
"urls": []
}
},
"protected": false,
"followers_count": 2145,
"friends_count": 18,
"listed_count": 328,
"created_at": "Wed Aug 22 02:06:33 +0000 2012",
"favourites_count": 57,
"utc_offset": 43200,
"time_zone": "Wellington"
}
}]
The generated output php file at /srv/output/test.php is as follows:
<?php $array = [ '0' => [ 'created_at' => 'Thu Jun 22 21:00:00 +0000 2017', 'id' => 877994604561387500, 'id_str' => '877994604561387520', 'text' => 'Creating a Grocery List Manager Using Angular, Part 1: Add & Display Items https://t.co/xFox78juL1 #Angular', 'truncated' => false, 'entities' => [ 'hashtags' => [ '0' => [ 'text' => 'Angular', 'indices' => [ '0' => 103, '1' => 111, ], ], ], 'symbols' => [], 'user_mentions' => [], 'urls' => [ '0' => [ 'url' => 'https://t.co/xFox78juL1', 'expanded_url' => 'http://buff.ly/2sr60pf', 'display_url' => 'buff.ly/2sr60pf', 'indices' => [ '0' => 79, '1' => 102, ], ], ], ], 'source' => '<a href="http://bufferapp.com" rel="nofollow">Buffer</a>', 'user' => [ 'id' => 772682964, 'id_str' => '772682964', 'name' => 'SitePoint JavaScript', 'screen_name' => 'SitePointJS', 'location' => 'Melbourne, Australia', 'description' => 'Keep up with JavaScript tutorials, tips, tricks and articles at SitePoint.', 'url' => 'http://t.co/cCH13gqeUK', 'entities' => [ 'url' => [ 'urls' => [ '0' => [ 'url' => 'http://t.co/cCH13gqeUK', 'expanded_url' => 'http://sitepoint.com/javascript', 'display_url' => 'sitepoint.com/javascript', 'indices' => [ '0' => 0, '1' => 22, ], ], ], ], 'description' => [ 'urls' => [], ], ], 'protected' => false, 'followers_count' => 2145, 'friends_count' => 18, 'listed_count' => 328, 'created_at' => 'Wed Aug 22 02:06:33 +0000 2012', 'favourites_count' => 57, 'utc_offset' => 43200, 'time_zone' => 'Wellington', ], ], ];
License
php-json-bender is released under the MIT Licence. See the bundled LICENSE file for details.
kristijorgji/php-json-bender 适用场景与选型建议
kristijorgji/php-json-bender 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.06k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 08 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「code」 「array」 「transform」 「generate」 「declaration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kristijorgji/php-json-bender 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kristijorgji/php-json-bender 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kristijorgji/php-json-bender 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A set of useful PHP classes.
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
Trait providing methods to set class properties with an array.
统计信息
- 总下载量: 1.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-10