{"id":16202014,"url":"https://github.com/atymic/json2dto","last_synced_at":"2025-09-02T17:09:08.784Z","repository":{"id":38031409,"uuid":"231837839","full_name":"atymic/json2dto","owner":"atymic","description":"Generate Data Transfer Objects directly from JSON objects","archived":false,"fork":false,"pushed_at":"2023-07-11T02:09:33.000Z","size":922,"stargazers_count":127,"open_issues_count":7,"forks_count":20,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T07:51:13.731Z","etag":null,"topics":["dto","laravel","spatie","vue"],"latest_commit_sha":null,"homepage":"https://json2dto.atymic.dev","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atymic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-04T22:33:00.000Z","updated_at":"2024-08-24T20:45:29.000Z","dependencies_parsed_at":"2023-01-23T21:47:25.463Z","dependency_job_id":null,"html_url":"https://github.com/atymic/json2dto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atymic%2Fjson2dto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atymic%2Fjson2dto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atymic%2Fjson2dto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atymic%2Fjson2dto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atymic","download_url":"https://codeload.github.com/atymic/json2dto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814907,"owners_count":20352037,"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":["dto","laravel","spatie","vue"],"created_at":"2024-10-10T09:45:15.015Z","updated_at":"2025-03-16T10:32:55.365Z","avatar_url":"https://github.com/atymic.png","language":"PHP","readme":"# Json 2 DTO\n\n[![Build Status](https://img.shields.io/github/workflow/status/atymic/json2dto/PHP?style=flat-square)](https://github.com/atymic/json2dto/actions) \n[![StyleCI](https://styleci.io/repos/231837839/shield)](https://styleci.io/repos/231837839) \n[![Latest Version on Packagist](https://img.shields.io/packagist/v/atymic/json2dto.svg?style=flat-square)](https://packagist.org/packages/atymic/json2dto) \n[![Total Downloads](https://img.shields.io/packagist/dt/atymic/json2dto.svg?style=flat-square)](https://packagist.org/packages/atymic/json2dto) \n\n[Spatie's Data Transfer Object](https://github.com/spatie/data-transfer-object) library is awesome, but typing out DTOs\ncan quickly become a chore. Inspired by Json2Typescript style tools, we built one for PHP DTOs.\n\n## Web Version\n\nTry it out at [https://json2dto.atymic.dev](https://json2dto.atymic.dev)  \nThe web version has all of the same tools as the cli version in an easy to use GUI. When generating nested DTOs, the \ntool will create a zip file.\n\n[![](https://repository-images.githubusercontent.com/231837839/14ed4680-2fb2-11ea-81fe-f06c5038b0dd)](https://json2dto.atymic.dev)\n\n## CLI Tool\n\nPrefer to use the tool locally? You can install `json2dto` via composer and generate files directly from json files.\n\n```bash\ncomposer global require atymic/json2dto # Install Globally\n\ncomposer require atymic/json2dto --dev # Install locally in a project\n```\n\n### Usage\n\nThe tool accepts json input either as a filename (second argument) or via `stdin`.  \nYou should run the tool in the root of your project (where your `composer.json` is located) as it will resolve namespaces\nbased on your PSR4 autoloading config. If you aren't using PSR4, your generated folder structure might not match.\n\n#### Examples\n\n```bash\n# Generate PHP 7.4 typed DTO\n./vendor/bin/json2dto generate \"App\\DTO\" test.json -name \"Test\" --typed\n\n# Generate PHP 8.0 typed DTO (DTO V3)\n./vendor/bin/json2dto generate \"App\\DTO\" test.json -name \"Test\" --v3\n\n# Generate a flexible DTO (with nested DTOs)\n./vendor/bin/json2dto generate \"App\\DTO\" test.json -name \"Test\" --nested --flexible\n\n# Generate a DTO from stdin\nwget http://example.com/cat.json | ./vendor/bin/json2dto generate \"App\\DTO\" -name Cat\n```\n\n#### Usage\n```\njson2dto generate [options] [--] \u003cnamespace\u003e [\u003cjson\u003e]\n\nArguments:\n  namespace                       Namespace to generate the class(es) in\n  json                            File containing the json string\n\nOptions:\n      --nested                    Generate nested DTOs\n      --typed                     Generate PHP \u003e= 7.4 strict typing\n      --flexible                  Generate a flexible DTO\n      --dry                       Dry run, print generated files\n      --v3                        Generate V3 DTO\n  -h, --help                      Display this help message\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatymic%2Fjson2dto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatymic%2Fjson2dto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatymic%2Fjson2dto/lists"}