PHPackages                             kristijorgji/php-json-bender - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kristijorgji/php-json-bender

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kristijorgji/php-json-bender
============================

A library to transform json to php array declarations.

1.0.0(7y ago)01.1kMITPHPPHP &gt;=7.1

Since Aug 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kristijorgji/php-json-bender)[ Packagist](https://packagist.org/packages/kristijorgji/php-json-bender)[ RSS](/packages/kristijorgji-php-json-bender/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-json-bender
===============

[](#php-json-bender)

Simple library to convert json strings to php array declarations.

Table of Contents
=================

[](#table-of-contents)

- [Installation](#installation)
- [Example](#Example)

Installation
------------

[](#installation)

```
composer require kristijorgji/php-json-bender
```

Example
-------

[](#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 &amp; 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": "Buffer",
  "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:

```
