mvccore/ext-tool-ts-generator

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

v5.2.3 2024-10-08 10:04 UTC

This package is auto-updated.

Last update: 2024-10-08 12:32:11 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();