spatie/typescript-transformer
Automatically generate TypeScript definitions from your PHP/Laravel code. spatie/typescript-transformer scans classes and types, then outputs .d.ts files so your frontend stays in sync with backend models, DTOs and enums with minimal manual typing.
Extensions allow packages to enrich the TypeScript transformer configuration. An extension implements the TypeScriptTransformerExtension interface:
use Spatie\TypeScriptTransformer\Support\Extensions\TypeScriptTransformerExtension;
use Spatie\TypeScriptTransformer\TypeScriptTransformerConfigFactory;
class MyExtension implements TypeScriptTransformerExtension
{
public function enrich(TypeScriptTransformerConfigFactory $factory): void
{
$factory->transformer(new MyCustomTransformer());
$factory->provider(new MyCustomProvider());
}
}
Register an extension in the configuration:
$config->extension(new MyExtension());
How can I help you explore Laravel packages today?