{"id":18352052,"url":"https://github.com/abgeo/json-to-popo","last_synced_at":"2026-03-09T10:02:04.672Z","repository":{"id":52413061,"uuid":"260008078","full_name":"ABGEO/json-to-popo","owner":"ABGEO","description":"Fill Plain Old PHP Object with JSON content.","archived":false,"fork":false,"pushed_at":"2021-04-29T21:41:00.000Z","size":74,"stargazers_count":13,"open_issues_count":2,"forks_count":7,"subscribers_count":2,"default_branch":"1.x","last_synced_at":"2025-12-22T00:08:44.390Z","etag":null,"topics":["composer","data-types","json","json-parser","php","php-library","plain-old-php-object","popo"],"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/ABGEO.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"ABGEO","open_collective":"ABGEO","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.me/ABGEO"]}},"created_at":"2020-04-29T18:23:10.000Z","updated_at":"2025-07-05T19:03:49.000Z","dependencies_parsed_at":"2022-09-07T17:36:18.415Z","dependency_job_id":null,"html_url":"https://github.com/ABGEO/json-to-popo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ABGEO/json-to-popo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABGEO%2Fjson-to-popo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABGEO%2Fjson-to-popo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABGEO%2Fjson-to-popo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABGEO%2Fjson-to-popo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ABGEO","download_url":"https://codeload.github.com/ABGEO/json-to-popo/tar.gz/refs/heads/1.x","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ABGEO%2Fjson-to-popo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30290921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["composer","data-types","json","json-parser","php","php-library","plain-old-php-object","popo"],"created_at":"2024-11-05T21:34:35.123Z","updated_at":"2026-03-09T10:02:04.655Z","avatar_url":"https://github.com/ABGEO.png","language":"PHP","funding_links":["https://patreon.com/ABGEO","https://opencollective.com/ABGEO","https://www.paypal.me/ABGEO"],"categories":[],"sub_categories":[],"readme":"# json-to-popo\n\nFill Plain Old PHP Object with JSON content.\n\n[![Build Status](https://travis-ci.com/ABGEO/json-to-popo.svg?branch=1.x)](https://travis-ci.com/ABGEO/json-to-popo?branch=1.x)\n[![Coverage Status](https://coveralls.io/repos/github/ABGEO/json-to-popo/badge.svg?branch=1.x)](https://coveralls.io/github/ABGEO/json-to-popo?branch=1.x)\n[![GitHub release](https://img.shields.io/github/release/ABGEO/json-to-popo.svg)](https://github.com/ABGEO/json-to-popo/releases)\n[![Packagist Version](https://img.shields.io/packagist/v/abgeo/json-to-popo.svg)](https://packagist.org/packages/abgeo/json-to-popo)\n[![GitHub license](https://img.shields.io/github/license/ABGEO/json-to-popo.svg)](https://github.com/ABGEO/json-to-popo/blob/master/LICENSE)\n\n## Installation\n\nYou can install this library with [Composer](https://getcomposer.org/):\n\n- `composer require abgeo/json-to-popo`\n\n## Usage\n\nInclude composer autoloader in your main file (Ex.: index.php)\n\n- `require __DIR__.'/../vendor/autoload.php';`\n\nConsider that you have `example.json` with the following content:\n\n```json\n{\n  \"firstName\": \"Temuri\",\n  \"lastName\": \"Takalandze\",\n  \"active\": true,\n  \"position\": {\n    \"title\": \"Developer\",\n    \"department\": {\n      \"title\": \"IT\"\n    }\n  }\n}\n```\n\nand several POPO classes to represent this JSON data:\n\n`Department.php`\n\n```php\n\u003c?php\n\nclass Department\n{\n    /**\n     * @var string\n     */\n    private $title;\n\n    // Getters and Setters here...\n}\n```\n\n`Position.php`\n\n```php\n\u003c?php\n\nclass Position\n{\n    /**\n     * @var string\n     */\n    private $title;\n\n    /**\n     * @var \\ABGEO\\POPO\\Example\\Department\n     */\n    private $department;\n\n    // Getters and Setters here...\n}\n```\n\n`Person.php`\n\n```php\n\u003c?php\n\nclass Person\n{\n    /**\n     * @var string\n     */\n    private $firstName;\n\n    /**\n     * @var string\n     */\n    private $lastName;\n\n    /**\n     * @var bool\n     */\n    private $active;\n\n    /**\n     * @var \\ABGEO\\POPO\\Example\\Position\n     */\n    private $position;\n\n    // Getters and Setters here...\n}\n```\n\n**Note**: All POPO properties must have full qualified `@var` annotation with the correct data type.\n\nNow you want to convert this JSON to POPO with relations. This package gives you this ability.\n\nLet's create new `ABGEO\\POPO\\Composer` object and read `example.json` content:\n\n```php\n$composer = new Composer();\n$jsonContent = file_get_contents(__DIR__ . '/example.json');\n```\n\nTime for magic! Call `composeObject()` with the contents of JSON and the main class, and this will give you POPO:\n\n```php\n$resultObject = $composer-\u003ecomposeObject($jsonContent, Person::class);\n```\n\nPrint `$resultObject`:\n\n```php\nvar_dump($resultObject);\n\n//class ABGEO\\POPO\\Example\\Person#2 (4) {\n//  private $firstName =\u003e\n//  string(6) \"Temuri\"\n//  private $lastName =\u003e\n//  string(10) \"Takalandze\"\n//  private $active =\u003e\n//  bool(true)\n//  private $position =\u003e\n//  class ABGEO\\POPO\\Example\\Position#4 (2) {\n//    private $title =\u003e\n//    string(9) \"Developer\"\n//    private $department =\u003e\n//    class ABGEO\\POPO\\Example\\Department#7 (1) {\n//      private $title =\u003e\n//      string(2) \"IT\"\n//    }\n//  }\n//}\n```\n\n**See full example [here](examples).**\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for details.\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## Authors\n\n- [**Temuri Takalandze**](https://abgeo.dev) - *Initial work*\n\n## License\n\nCopyright © 2020 [Temuri Takalandze](https://abgeo.dev).  \nReleased under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabgeo%2Fjson-to-popo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabgeo%2Fjson-to-popo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabgeo%2Fjson-to-popo/lists"}