{"id":18610581,"url":"https://github.com/ixnode/php-container","last_synced_at":"2026-03-01T04:06:35.543Z","repository":{"id":65145550,"uuid":"583682632","full_name":"ixnode/php-container","owner":"ixnode","description":"A collection of various PHP container classes like JSON, File, etc.","archived":false,"fork":false,"pushed_at":"2024-02-25T21:37:47.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T21:20:22.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ixnode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-30T15:01:39.000Z","updated_at":"2024-04-26T21:20:22.047Z","dependencies_parsed_at":"2023-11-18T23:25:27.195Z","dependency_job_id":"e20c1993-b7fe-428d-b4c8-5eb6a5489746","html_url":"https://github.com/ixnode/php-container","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"28271cebaaf86d10272e0665328577161f3cc8b3"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ixnode%2Fphp-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ixnode","download_url":"https://codeload.github.com/ixnode/php-container/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239317139,"owners_count":19619116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T03:11:08.013Z","updated_at":"2025-11-02T21:30:25.015Z","avatar_url":"https://github.com/ixnode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Container\n\n[![Release](https://img.shields.io/github/v/release/ixnode/php-container)](https://github.com/ixnode/php-container/releases)\n[![](https://img.shields.io/github/release-date/ixnode/php-container)](https://github.com/twelvepics-com/php-calendar-builder/releases)\n[![PHP](https://img.shields.io/badge/PHP-^8.0-777bb3.svg?logo=php\u0026logoColor=white\u0026labelColor=555555\u0026style=flat)](https://www.php.net/supported-versions.php)\n[![PHPStan](https://img.shields.io/badge/PHPStan-Level%20Max-777bb3.svg?style=flat)](https://phpstan.org/user-guide/rule-levels)\n[![PHPUnit](https://img.shields.io/badge/PHPUnit-Unit%20Tests-6b9bd2.svg?style=flat)](https://phpunit.de)\n[![PHPCS](https://img.shields.io/badge/PHPCS-PSR12-416d4e.svg?style=flat)](https://www.php-fig.org/psr/psr-12/)\n[![PHPMD](https://img.shields.io/badge/PHPMD-ALL-364a83.svg?style=flat)](https://github.com/phpmd/phpmd)\n[![Rector - Instant Upgrades and Automated Refactoring](https://img.shields.io/badge/Rector-PHP%208.0-73a165.svg?style=flat)](https://github.com/rectorphp/rector)\n[![LICENSE](https://img.shields.io/github/license/ixnode/php-container)](https://github.com/ixnode/php-container/blob/master/LICENSE)\n\n\u003e A collection of various PHP container classes like JSON, File, etc.\n\n## 1) Installation\n\n```bash\ncomposer require ixnode/php-container\n```\n\n```bash\nvendor/bin/php-container -V\n```\n\n```bash\nphp-container 0.1.0 (12-19-2022 01:17:26) - Björn Hempel \u003cbjoern@hempel.li\u003e\n```\n\n## 2) Usage\n\n### 2.1) File\n\n```php\nuse Ixnode\\PhpContainer\\File;\n```\n\n#### 2.1.1) Check if file exists\n\n```php\n$exists = (new File('path-to-file'))-\u003eexist();\n```\n\n```php\ntrue || false\n```\n\n#### 2.1.2) Get the filesize (`integer` value)\n\n```php\n$fileSize = (new File('path-to-file'))-\u003egetFileSize();\n```\n\n```php\n1523943\n```\n\n#### 2.1.3) Get the filesize (human readable)\n\n```php\n$fileSizeHuman = (new File('path-to-file'))-\u003egetFileSizeHuman();\n```\n\n```php\n1.45 MB\n```\n\n#### 2.1.4) Get the file content\n\n```php\n$content = (new File('path-to-file'))-\u003egetContentAsText();\n```\n\n```php\nline 1\nline 2\nline 3\n...\n```\n\n#### 2.1.5) Get the file content as JSON object\n\n```php\n$content = (new File('path-to-json-file'))-\u003egetJson()-\u003egetJsonStringFormatted();\n```\n\n```php\n{\n    \"data\": \"Content of file 'path-to-json-file'.\"\n}\n```\n\n### 2.2) JSON\n\n```php\nuse Ixnode\\PhpContainer\\Json;\n```\n\n#### 2.2.1) Convert `array` to JSON\n\n```php\n$json = (new Json(['data' =\u003e 'json']))-\u003egetJsonStringFormatted();\n```\n\n```json\n{\n    \"data\": \"json\"\n}\n```\n\n#### 2.2.2) Convert JSON to `array`\n\n```php\n$array = (new Json('{\"data\": \"json\"}'))-\u003egetArray();\n```\n\n```php\n[\n    'data' =\u003e 'json',\n]\n```\n\n#### 2.2.3) Convert JSON file to `array`\n\n```php\n$array = (new Json(new File('path-to-json-file')))-\u003egetArray();\n```\n\n#### 2.2.4) Access to JSON object\n\n```php\n$json = (new Json([\n    'key1' =\u003e 'value1',\n    'key2' =\u003e [\n        'associative' =\u003e [\n            'name' =\u003e 'Test',\n            'id' =\u003e 123\n        ],\n        'indexed' =\u003e [1, 2, 3],\n    ],\n    'key3' =\u003e 'value3',\n    'key4' =\u003e 'value4',\n    'key5' =\u003e 'value5',\n]));\n```\n\n```php\nprint $json-\u003egetKeyString(['key2', 'associative', 'name']);\n// return value: (string) 'Test'\n```\n\n```php\nprint $json-\u003egetKeyInteger(['key2', 'indexed', 0]);\n// return value: (int) 1\n```\n\n```php\nprint_r($json-\u003egetKeyArray(['key2', 'indexed']));\n// return value: (array) [1, 2, 3]\n```\n\n#### 2.2.5) Build a new `array` from JSON\n\n```php\n$array = (new Json('[{\"key1\": 111, \"key2\": \"222\"},{\"key1\": 333, \"key2\": \"444\"}]'))-\u003ebuildArray(\n    [\n        /* path []['key1'] as area1 */\n        'area1' =\u003e [['key1']],\n        /* path []['key2'] as area2 */\n        'area2' =\u003e [['key2']],\n    ]\n);\n```\n\n```php\n[\n    'area1' =\u003e [111, 333],\n    'area2' =\u003e ['222', '444'],\n]\n```\n\n### 2.3) CSV\n\n```php\nuse Ixnode\\PhpContainer\\Csv;\n```\n\n#### 2.3.1) Parse CSV file to array\n\n```php\n$array = (new Csv(new File('path-to-csv-file')))-\u003egetArray();\n```\n\nContent of \"path-to-csv-file\":\n\n```text\n\"headerLine1Cell1\";\"headerLine1Cell2\"\n\"valueLine2Cell1\";\"valueLine2Cell2\"\n\"valueLine3Cell1\";\"valueLine3Cell2\"\n```\n\nResponse:\n\n```php\n[\n    [\n        'headerLine1Cell1' =\u003e 'valueLine2Cell1',\n        'headerLine1Cell2' =\u003e 'valueLine2Cell2',\n    ],    \n    [\n        'headerLine1Cell1' =\u003e 'valueLine3Cell1',\n        'headerLine1Cell2' =\u003e 'valueLine3Cell2',\n    ],\n    ...\n]\n```\n\n### 2.4) Curl\n\n```php\nuse Ixnode\\PhpContainer\\Curl;\n```\n\n#### 2.4.1) Return the response value from 'URL'\n\n```php\n$text = (new Curl('URL')-\u003egetContentAsText();\n```\n\n### 2.5) Image\n\n```php\nuse Ixnode\\PhpContainer\\Image;\n```\n\n#### 2.5.1) Return width of given image.\n\n```php\n$imageWidth = (new Image(new File('path-to-json-file')))-\u003egetWidth();\n```\n\n#### 2.5.2) Returns a resized image.\n\n```php\n$imageString = (new Image(new File('path-to-json-file')))-\u003egetImageString(1000, Image::FORMAT_JPG, 85);\n```\n\n## 3.) Development\n\n```bash\ngit clone git@github.com:ixnode/php-container.git \u0026\u0026 cd php-container\n```\n\n```bash\ncomposer install\n```\n\n```bash\ncomposer test\n```\n\n## 4.) License\n\nThis tool is licensed under the MIT License - see the [LICENSE](/LICENSE) file for details","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fixnode%2Fphp-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fixnode%2Fphp-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fixnode%2Fphp-container/lists"}