PHPackages                             riverwaysoft/php-converter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. riverwaysoft/php-converter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

riverwaysoft/php-converter
==========================

PHP converter to TypeScript / Dart

0.9.1(2mo ago)954.9k↓50%2[21 issues](https://github.com/riverwaysoft/php-converter/issues)[1 PRs](https://github.com/riverwaysoft/php-converter/pulls)GPL-3.0-or-laterPHPPHP &gt;=8.1CI passing

Since Aug 21Pushed 2mo agoCompare

[ Source](https://github.com/riverwaysoft/php-converter)[ Packagist](https://packagist.org/packages/riverwaysoft/php-converter)[ RSS](/packages/riverwaysoft-php-converter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (40)Versions (115)Used By (0)

php-converter [![Latest Version on Packagist](https://camo.githubusercontent.com/e2a666fd8d085bc7fdfdf982737cd4d02c59428e3662ba5dc4012256a26d477e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7269766572776179736f66742f7068702d636f6e7665727465722e737667)](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://camo.githubusercontent.com/10739c9b18bc09ab7df1cda25edc87aa25e535f05db665f32073255056540fdb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7269766572776179736f66742f7068702d636f6e7665727465722e737667)](https://packagist.org/packages/riverwaysoft/php-converter)
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#php-converter----)

[![Screen Shot 2022-10-07 at 09 04 35](https://user-images.githubusercontent.com/22447849/194478818-7276da5c-bf5e-4ad2-8efd-6463c53d01d3.png)](https://user-images.githubusercontent.com/22447849/194478818-7276da5c-bf5e-4ad2-8efd-6463c53d01d3.png)

Generates TypeScript &amp; Dart out of your PHP DTO classes.

Why?
----

[](#why)

Statically 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.

Requirements
------------

[](#requirements)

PHP 8.0 or above

Quick start
-----------

[](#quick-start)

1. Installation

```
composer require riverwaysoft/php-converter --dev
```

If the installation leads to dependency conflicts, consider using the [standalone Phar version](docs/standalone-installation.md) of the package.

2. Mark a few classes with the #\[Dto\] annotation to convert them into TypeScript or Dart.

```
use Riverwaysoft\PhpConverter\Filter\Attributes\Dto;

#[Dto]
class UserOutput
{
    public string $id;
    public int $age;
    public ?UserOutput $bestFriend;
    /** @var UserOutput[] */
    public array $friends;
}
```

4. Run the CLI command to generate TypeScript

```
vendor/bin/php-converter --from=/path/to/project/src --to=.
```

This will generate a file `generated.ts` with the following content:

```
type UserOutput = {
  id: string;
  age: number;
  bestFriend: UserOutput | null;
  friends: UserOutput[];
}
```

Features
--------

[](#features)

- Supports all PHP data types including union types, nullable types, and enums.
- Supports PHP DocBlock types, e.g., `User[]`, `int[][]|null`, and generics thanks to [phpstan/phpdoc-parser](https://github.com/phpstan/phpdoc-parser)
- Custom type resolvers (for instance, for `DateTimeImmutable`).
- Generate a single output file or multiple files (1 type per file).
- Option to override the generation logic.
- Flexible class filters with the option to use your own filters.
- Generate API client from Symfony or API Platform code.

Customization
-------------

[](#customization)

If you'd like to customize the conversion process, you need to copy the config script to your project folder:

```
cp vendor/riverwaysoft/php-converter/bin/default-config.php config/ts-config.php

```

Now you can customize this config and run the php-converter using the following script:

```
vendor/bin/php-converter --from=/path/to/project/src --to=. --config=config/ts-config.php
```

Documentation
-------------

[](#documentation)

- [Class filtering](docs/class-filtering.md)
- [Customize output](docs/customize-output-generation.md)
- [Unknown type resolvers](docs/unknown-type-resolvers.md)
- [Other languages support](docs/other-language-support.md)
- [Troubleshooting](docs/troubleshooting.md)
- [Development](docs/development.md)
- [Standalone installation](docs/standalone-installation.md)

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance66

Regular maintenance activity

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~17 days

Recently: every ~171 days

Total

98

Last Release

68d ago

PHP version history (2 changes)0.7.9.11PHP &gt;=8.0

0.9.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c3f6a6a42f0ae7eea505176bebc2dae91e17d01918cd478115b18c68c764e5cd?d=identicon)[mitalcoi](/maintainers/mitalcoi)

![](https://www.gravatar.com/avatar/350ee43e8468e211372522e3733fb4b9bcf326e08aafc8acd1cc8677bb4c3bfa?d=identicon)[kubk](/maintainers/kubk)

---

Top Contributors

[![kubk](https://avatars.githubusercontent.com/u/22447849?v=4)](https://github.com/kubk "kubk (180 commits)")[![mitalcoi](https://avatars.githubusercontent.com/u/3224226?v=4)](https://github.com/mitalcoi "mitalcoi (8 commits)")[![KoNekoD](https://avatars.githubusercontent.com/u/108808201?v=4)](https://github.com/KoNekoD "KoNekoD (5 commits)")

---

Tags

code-converterdartphptypescript

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/riverwaysoft-php-converter/health.svg)

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

###  Alternatives

[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M568](/packages/symfony-maker-bundle)[infection/infection

Infection is a Mutation Testing framework for PHP. The mutation adequacy score can be used to measure the effectiveness of a test set in terms of its ability to detect faults.

2.2k26.2M1.8k](/packages/infection-infection)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)

PHPackages © 2026

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