mvccore/ext-tool-ts-generator

MvcCore - 扩展 - 工具 - TypeScript 生成器 - 从 PHP 等价物中轻松生成 TypeScript 类、接口或枚举的实用工具。

v5.2.2 2024-02-13 15:17 UTC

This package is auto-updated.

Last update: 2024-09-13 16:54:14 UTC


README

Latest Stable Version License PHP Version

安装

composer require mvccore/ext-tool-ts-generator

功能

扩展,可以从 PHP 等价物中轻松生成 TypeScript 模型类、接口或枚举。

用法

<?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();