Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vagebnd/runtype
Generate TypeScript interfaces from Laravel Models & Resources
https://github.com/vagebnd/runtype
generator laravel php8 typescript
Last synced: 17 days ago
JSON representation
Generate TypeScript interfaces from Laravel Models & Resources
- Host: GitHub
- URL: https://github.com/vagebnd/runtype
- Owner: vagebnd
- License: mit
- Created: 2023-02-13T21:37:03.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-02T22:58:49.000Z (8 months ago)
- Last Synced: 2024-10-13T18:39:11.938Z (about 1 month ago)
- Topics: generator, laravel, php8, typescript
- Language: PHP
- Homepage: https://runtype.vagebond.nl
- Size: 115 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Typescript Generator: Runtype
[![Latest Version on Packagist](https://img.shields.io/packagist/v/vagebond/runtype.svg?style=flat-square)](https://packagist.org/packages/vagebond/runtype)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/vagebnd/runtype/run-tests.yml?branch=main&label=tests)](https://github.com/vagebnd/runtype/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/vagebnd/runtype/fix-php-code-style-issues.yml?branch=main)](https://github.com/vagebnd/runtype/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/vagebond/runtype.svg?style=flat-square)](https://packagist.org/packages/vagebond/runtype)Generate TypeScript interfaces from Laravel Models & Resources
This resource:
```PHP
use Illuminate\Http\Resources\Json\JsonResource;/** @mixin \App\Models\Product */
class ProductResource extends JsonResource
{
public $showHiddenData = false;public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'hidden' => $this->when($this->showHiddenData, false),
];
}
}
```will be converted into this interface:
```typescript
export interface ProductResourceType {
id: number;
name: string;
hidden?: boolean;
}
```You can read the full documentation [here](https://runtype.vagebond.nl/).
## Installation
You can install the package via composer:
```bash
composer require vagebond/runtype --dev
```You can publish the config file with:
```bash
php artisan vendor:publish --tag="runtype-config"
```## Usage
```bash
php artisan runtype:generate
```## Testing
```bash
composer test
```## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Gianluca Riggio](https://github.com/mxaGianluca)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.