Always wanted type safety within PHP and TypeScript without duplicating a lot of code? Then you will like this package! Let's say you have an enum:
class Languages extends Enum
{
const TYPESCRIPT = 'typescript';
const PHP = 'php';
}Wouldn't it be cool if you could have an automatically generated TypeScript definition like this:
export type Languages = 'typescript' | 'php';This package will automatically generate such definitions for you, the only thing you have to do is adding this annotation:
/** @typescript **/
class Languages extends Enum
{
const TYPESCRIPT = 'typescript';
const PHP = 'php';
}You can even take it a bit further and generate TypeScript from classes:
/** @typescript */
class User
{
public int $id;
public string $name;
public ?string $address;
}This will be transformed to:
export type User = {
id: number;
name: string;
address: string | null;
}Want to know more? You can find the documentation here.
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.