mvccore/ext-tool-ts-generator

MvcCore - Extension - Tool - TypeScript Generator - utility to easilly generate TypeScript classes, interfaces or enums from PHP equivalents.

v5.3.0 2024-11-21 15:01 UTC

This package is auto-updated.

Last update: 2024-11-21 16:01:07 UTC


README

Latest Stable Version License PHP Version

Installation

composer require mvccore/ext-tool-ts-generator

Features

Extension to easilly generate TypeScript model classes, interfaces or enums from PHP equivalents.

Usage

<?php

include_once('vendor/autoload.php');

use \MvcCore\Ext\Tools\TsGenerator;

TsGenerator::CreateInstance()
	->SetType(
		new \ReflectionClass(\PhpObjects\BaseClass::class)
	)
	->SetPropsFlags(
		TsGenerator::PROPS_INHERIT_PROTECTED
	)
	->SetTargetPath(
		__DIR__ . '/Ts/Custom/ClassName.d.ts'
	)
	->SetWriteFlags(
		TsGenerator::WRITE_INTERFACE
		| TsGenerator::WRITE_DECLARE
		// | TsGenerator::WRITE_EXPORT
	)
	->SetExcludedPropsNames(['db'])
	//->SetCustomName('Custom.ClassName')
	->Parse()
	->Write();