Typographos
Generate TypeScript types from your PHP classes
Composer
composer require letamanoir/typographos
See It in Action
Typographos transforms your PHP classes into perfectly typed TypeScript definitions with minimal setup. Just add one attribute to your PHP classes and your types stay in sync automatically. Built for modern PHP 8.4+ with full support for unions, nullables, and complex types.
app/DTO/User.php
<?php
namespace App\DTO;
use Typographos\Attributes\TypeScript;
#[TypeScript]
class User
{
public function __construct(
public string $name,
public int $age,
public ?string $email = null,
) {}
}
generated.d.ts
declare namespace App {
export namespace DTO {
export interface User {
name: string;
age: number;
email: string | null;
}
}
}