{"id":46893806,"url":"https://github.com/riverwaysoft/php-converter","last_synced_at":"2026-03-10T23:26:27.644Z","repository":{"id":38678757,"uuid":"393954827","full_name":"riverwaysoft/php-converter","owner":"riverwaysoft","description":"Generates TypeScript \u0026 Dart out of your PHP DTO classes.","archived":false,"fork":false,"pushed_at":"2024-04-29T02:12:46.000Z","size":3401,"stargazers_count":9,"open_issues_count":29,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-20T02:45:15.857Z","etag":null,"topics":["code-converter","dart","php","typescript"],"latest_commit_sha":null,"homepage":"","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/riverwaysoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2021-08-08T12:31:27.000Z","updated_at":"2025-02-02T18:51:09.000Z","dependencies_parsed_at":"2023-12-17T15:30:22.309Z","dependency_job_id":"ca7fb3f2-d5e7-4931-b787-d6dc9a74bc39","html_url":"https://github.com/riverwaysoft/php-converter","commit_stats":null,"previous_names":["riverwaysoft/php-converter","riverwaysoft/dto-converter"],"tags_count":96,"template":false,"template_full_name":null,"purl":"pkg:github/riverwaysoft/php-converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverwaysoft%2Fphp-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverwaysoft%2Fphp-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverwaysoft%2Fphp-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverwaysoft%2Fphp-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riverwaysoft","download_url":"https://codeload.github.com/riverwaysoft/php-converter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverwaysoft%2Fphp-converter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30329697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T05:25:20.737Z","status":"ssl_error","status_checked_at":"2026-03-10T05:25:17.430Z","response_time":106,"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":["code-converter","dart","php","typescript"],"created_at":"2026-03-10T23:26:27.093Z","updated_at":"2026-03-10T23:26:27.636Z","avatar_url":"https://github.com/riverwaysoft.png","language":"PHP","readme":"# php-converter [![Latest Version on Packagist](https://img.shields.io/packagist/v/riverwaysoft/php-converter.svg)](https://packagist.org/packages/riverwaysoft/php-converter) [![Tests](https://github.com/riverwaysoft/php-converter/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/riverwaysoft/php-converter/actions/workflows/php.yml) [![PHPStan](https://github.com/riverwaysoft/php-converter/actions/workflows/static_analysis.yml/badge.svg?branch=master)](https://github.com/riverwaysoft/php-converter/actions/workflows/static_analysis.yml) [![Total Downloads](https://img.shields.io/packagist/dt/riverwaysoft/php-converter.svg)](https://packagist.org/packages/riverwaysoft/php-converter)\n\n\u003cimg width=\"818\" alt=\"Screen Shot 2022-10-07 at 09 04 35\" src=\"https://user-images.githubusercontent.com/22447849/194478818-7276da5c-bf5e-4ad2-8efd-6463c53d01d3.png\"\u003e\n\nGenerates TypeScript \u0026 Dart out of your PHP DTO classes.\n\n## Why?\nStatically typed languages like TypeScript or Dart are great because they allow catching bugs without even running your code. But unless there are well-defined contracts between the API and consumer apps, you may find yourself frequently adjusting outdated typings whenever the API  changes. This library generates types for you, enabling you to move faster and encounter fewer bugs.\n\n## Requirements\n\nPHP 8.0 or above\n\n## Quick start\n\n1) Installation\n```bash\ncomposer require riverwaysoft/php-converter --dev\n```\n\nIf the installation leads to dependency conflicts, consider using the [standalone Phar version](docs/standalone-installation.md) of the package.\n\n2) Mark a few classes with the #[Dto] annotation to convert them into TypeScript or Dart.\n\n```php\nuse Riverwaysoft\\PhpConverter\\Filter\\Attributes\\Dto;\n\n#[Dto]\nclass UserOutput\n{\n    public string $id;\n    public int $age;\n    public ?UserOutput $bestFriend;\n    /** @var UserOutput[] */\n    public array $friends;\n}\n```\n\n4) Run the CLI command to generate TypeScript\n```bash\nvendor/bin/php-converter --from=/path/to/project/src --to=.\n```\n\nThis will generate a file `generated.ts` with the following content:\n\n```typescript\ntype UserOutput = {\n  id: string;\n  age: number;\n  bestFriend: UserOutput | null;\n  friends: UserOutput[];\n}\n```\n\n## Features\n- Supports all PHP data types including union types, nullable types, and enums.\n- Supports PHP DocBlock types, e.g., `User[]`, `int[][]|null`, and generics thanks to [phpstan/phpdoc-parser](https://github.com/phpstan/phpdoc-parser)\n- Custom type resolvers (for instance, for `DateTimeImmutable`).\n- Generate a single output file or multiple files (1 type per file).\n- Option to override the generation logic.\n- Flexible class filters with the option to use your own filters.\n- Generate API client from Symfony or API Platform code.\n\n## Customization\nIf you'd like to customize the conversion process, you need to copy the config script to your project folder:\n\n```\ncp vendor/riverwaysoft/php-converter/bin/default-config.php config/ts-config.php\n``` \n\nNow you can customize this config and run the php-converter using the following script:\n```bash\nvendor/bin/php-converter --from=/path/to/project/src --to=. --config=config/ts-config.php\n```\n\n## Documentation\n- [Class filtering](docs/class-filtering.md)\n- [Customize output](docs/customize-output-generation.md)\n- [Unknown type resolvers](docs/unknown-type-resolvers.md)\n- [Other languages support](docs/other-language-support.md)\n- [Troubleshooting](docs/troubleshooting.md)\n- [Development](docs/development.md)\n- [Standalone installation](docs/standalone-installation.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friverwaysoft%2Fphp-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friverwaysoft%2Fphp-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friverwaysoft%2Fphp-converter/lists"}