Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spatie/typescript-transformer
Transform PHP types to TypeScript
https://github.com/spatie/typescript-transformer
Last synced: 5 days ago
JSON representation
Transform PHP types to TypeScript
- Host: GitHub
- URL: https://github.com/spatie/typescript-transformer
- Owner: spatie
- License: mit
- Created: 2020-05-22T12:49:03.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-11-04T07:47:35.000Z (4 months ago)
- Last Synced: 2025-02-09T15:01:34.772Z (12 days ago)
- Language: PHP
- Homepage: https://docs.spatie.be/typescript-transformer/v2/introduction/
- Size: 1.46 MB
- Stars: 296
- Watchers: 7
- Forks: 36
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Transform PHP types to TypeScript
[](https://packagist.org/packages/spatie/typescript-transformer)
[](https://github.com/spatie/typescript-transformer/actions?query=workflow%3Arun-tests)
[](https://github.com/spatie/typescript-transformer/actions?query=workflow%3A%22Check+%26+fix+styling%22)
[](https://github.com/spatie/typescript-transformer/actions/workflows/phpstan.yml)
[](https://packagist.org/packages/spatie/typescript-transformer)This package allows you to convert PHP classes to TypeScript.
This class...
```php
/** @typescript */
class User
{
public int $id;
public string $name;
public ?string $address;
}
```... will be converted to this TypeScript type:
```ts
export type User = {
id: number;
name: string;
address: string | null;
}
```Here's another example.
```php
class Languages extends Enum
{
const TYPESCRIPT = 'typescript';
const PHP = 'php';
}
```The `Languages` enum will be converted to:
```tsx
export type Languages = 'typescript' | 'php';
```You can find the full documentation [here](https://docs.spatie.be/typescript-transformer/v2/introduction/).
## Support us
[
](https://spatie.be/github-ad-click/typescript-transformer)
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
## Installation
You can install this package via composer:
```bash
composer require spatie/typescript-transformer
```## Testing
``` bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
## Security
If you've found a bug regarding security please mail [[email protected]](mailto:[email protected]) instead of using the issue tracker.
## Credits
- [Ruben Van Assche](https://github.com/rubenvanassche)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.