PHPackages                             ixnode/php-container - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. ixnode/php-container

ActiveLibrary[File &amp; Storage](/categories/file-storage)

ixnode/php-container
====================

PHP Container - A collection of various PHP container classes like JSON, File, etc.

1.0.27(6mo ago)11.2k5MITPHPPHP ^8.0

Since Dec 30Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/ixnode/php-container)[ Packagist](https://packagist.org/packages/ixnode/php-container)[ RSS](/packages/ixnode-php-container/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (13)Versions (54)Used By (5)

PHP Container
=============

[](#php-container)

[![Release](https://camo.githubusercontent.com/c9d0e711ff02ca81669c0c7ef38ec902f9c05415d2d66da1b42d8a266fc6f1f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f69786e6f64652f7068702d636f6e7461696e6572)](https://github.com/ixnode/php-container/releases)[![](https://camo.githubusercontent.com/f57df11e98bcef6063fb6d706bd81238cecb6636b8aed12d704816f9afa7e079/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f69786e6f64652f7068702d636f6e7461696e6572)](https://github.com/twelvepics-com/php-calendar-builder/releases)[![PHP](https://camo.githubusercontent.com/1bbf13029689f8044cc3080b0010efacbee3d0ccebdcf17e9538990f0f53a6c8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e302d3737376262332e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d353535353535267374796c653d666c6174)](https://www.php.net/supported-versions.php)[![PHPStan](https://camo.githubusercontent.com/29fcb055286f72da2b9c961f987152d1ac26a91d6cea221174abe7e01b5b7857/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d3737376262332e7376673f7374796c653d666c6174)](https://phpstan.org/user-guide/rule-levels)[![PHPUnit](https://camo.githubusercontent.com/de101a446df383674178b80c404288664983cc6de751737d976d3df023942af9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d556e697425323054657374732d3662396264322e7376673f7374796c653d666c6174)](https://phpunit.de)[![PHPCS](https://camo.githubusercontent.com/ee1fdc76b568e414c96c160eb608dd4680475a67d714661b70a3b3c43f6ded54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50485043532d50535231322d3431366434652e7376673f7374796c653d666c6174)](https://www.php-fig.org/psr/psr-12/)[![PHPMD](https://camo.githubusercontent.com/223a2afede2bd4bf4d524b7610277838a5d75504f7087fc6c36847b81a80ab43/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048504d442d414c4c2d3336346138332e7376673f7374796c653d666c6174)](https://github.com/phpmd/phpmd)[![Rector - Instant Upgrades and Automated Refactoring](https://camo.githubusercontent.com/8d7c652eaf1b6eb57b5a680405850a363a674f864594232acb8fc5e8a8c062ab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f526563746f722d504850253230382e302d3733613136352e7376673f7374796c653d666c6174)](https://github.com/rectorphp/rector)[![LICENSE](https://camo.githubusercontent.com/681963b607a393b3a463d58c01445286c802500a465604b46b3e7612784ebeea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f69786e6f64652f7068702d636f6e7461696e6572)](https://github.com/ixnode/php-container/blob/master/LICENSE)

> A collection of various PHP container classes like JSON, File, etc.

1) Installation
---------------

[](#1-installation)

```
composer require ixnode/php-container
```

```
vendor/bin/php-container -V
```

```
php-container 0.1.0 (12-19-2022 01:17:26) - Björn Hempel
```

2) Usage
--------

[](#2-usage)

### 2.1) File

[](#21-file)

```
use Ixnode\PhpContainer\File;
```

#### 2.1.1) Check if file exists

[](#211-check-if-file-exists)

```
$exists = (new File('path-to-file'))->exist();
```

```
true || false
```

#### 2.1.2) Get the filesize (`integer` value)

[](#212-get-the-filesize-integer-value)

```
$fileSize = (new File('path-to-file'))->getFileSize();
```

```
1523943
```

#### 2.1.3) Get the filesize (human readable)

[](#213-get-the-filesize-human-readable)

```
$fileSizeHuman = (new File('path-to-file'))->getFileSizeHuman();
```

```
1.45 MB
```

#### 2.1.4) Get the file content

[](#214-get-the-file-content)

```
$content = (new File('path-to-file'))->getContentAsText();
```

```
line 1
line 2
line 3
...
```

#### 2.1.5) Get the file content as JSON object

[](#215-get-the-file-content-as-json-object)

```
$content = (new File('path-to-json-file'))->getJson()->getJsonStringFormatted();
```

```
{
    "data": "Content of file 'path-to-json-file'."
}
```

### 2.2) JSON

[](#22-json)

```
use Ixnode\PhpContainer\Json;
```

#### 2.2.1) Convert `array` to JSON

[](#221-convert-array-to-json)

```
$json = (new Json(['data' => 'json']))->getJsonStringFormatted();
```

```
{
    "data": "json"
}
```

#### 2.2.2) Convert JSON to `array`

[](#222-convert-json-to-array)

```
$array = (new Json('{"data": "json"}'))->getArray();
```

```
[
    'data' => 'json',
]
```

#### 2.2.3) Convert JSON file to `array`

[](#223-convert-json-file-to-array)

```
$array = (new Json(new File('path-to-json-file')))->getArray();
```

#### 2.2.4) Access to JSON object

[](#224-access-to-json-object)

```
$json = (new Json([
    'key1' => 'value1',
    'key2' => [
        'associative' => [
            'name' => 'Test',
            'id' => 123
        ],
        'indexed' => [1, 2, 3],
    ],
    'key3' => 'value3',
    'key4' => 'value4',
    'key5' => 'value5',
]));
```

```
print $json->getKeyString(['key2', 'associative', 'name']);
// return value: (string) 'Test'
```

```
print $json->getKeyInteger(['key2', 'indexed', 0]);
// return value: (int) 1
```

```
print_r($json->getKeyArray(['key2', 'indexed']));
// return value: (array) [1, 2, 3]
```

#### 2.2.5) Build a new `array` from JSON

[](#225-build-a-new-array-from-json)

```
$array = (new Json('[{"key1": 111, "key2": "222"},{"key1": 333, "key2": "444"}]'))->buildArray(
    [
        /* path []['key1'] as area1 */
        'area1' => [['key1']],
        /* path []['key2'] as area2 */
        'area2' => [['key2']],
    ]
);
```

```
[
    'area1' => [111, 333],
    'area2' => ['222', '444'],
]
```

### 2.3) CSV

[](#23-csv)

```
use Ixnode\PhpContainer\Csv;
```

#### 2.3.1) Parse CSV file to array

[](#231-parse-csv-file-to-array)

```
$array = (new Csv(new File('path-to-csv-file')))->getArray();
```

Content of "path-to-csv-file":

```
"headerLine1Cell1";"headerLine1Cell2"
"valueLine2Cell1";"valueLine2Cell2"
"valueLine3Cell1";"valueLine3Cell2"

```

Response:

```
[
    [
        'headerLine1Cell1' => 'valueLine2Cell1',
        'headerLine1Cell2' => 'valueLine2Cell2',
    ],
    [
        'headerLine1Cell1' => 'valueLine3Cell1',
        'headerLine1Cell2' => 'valueLine3Cell2',
    ],
    ...
]
```

### 2.4) Curl

[](#24-curl)

```
use Ixnode\PhpContainer\Curl;
```

#### 2.4.1) Return the response value from 'URL'

[](#241-return-the-response-value-from-url)

```
$text = (new Curl('URL')->getContentAsText();
```

### 2.5) Image

[](#25-image)

```
use Ixnode\PhpContainer\Image;
```

#### 2.5.1) Return width of given image.

[](#251-return-width-of-given-image)

```
$imageWidth = (new Image(new File('path-to-json-file')))->getWidth();
```

#### 2.5.2) Returns a resized image.

[](#252-returns-a-resized-image)

```
$imageString = (new Image(new File('path-to-json-file')))->getImageString(1000, Image::FORMAT_JPG, 85);
```

3.) Development
---------------

[](#3-development)

```
git clone git@github.com:ixnode/php-container.git && cd php-container
```

```
composer install
```

```
composer test
```

4.) License
-----------

[](#4-license)

This tool is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance66

Regular maintenance activity

Popularity18

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 81.7% 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.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~71 days

Total

53

Last Release

203d ago

Major Versions

0.1.24 → 1.0.02024-12-07

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29461791?v=4)[ixnode](/maintainers/ixnode)[@ixnode](https://github.com/ixnode)

---

Top Contributors

[![bjoern-hempel](https://avatars.githubusercontent.com/u/5531245?v=4)](https://github.com/bjoern-hempel "bjoern-hempel (89 commits)")[![bjoernhempel](https://avatars.githubusercontent.com/u/222443752?v=4)](https://github.com/bjoernhempel "bjoernhempel (20 commits)")

---

Tags

phpjsoncontainerdatafile

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ixnode-php-container/health.svg)

```
[![Health](https://phpackages.com/badges/ixnode-php-container/health.svg)](https://phpackages.com/packages/ixnode-php-container)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[blueimp/jquery-file-upload

File Upload widget for jQuery.

141.5M20](/packages/blueimp-jquery-file-upload)

PHPackages © 2026

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