mvccore / ext-tool-ts-generator
MvcCore - 扩展 - 工具 - TypeScript 生成器 - 从 PHP 等价物中轻松生成 TypeScript 类、接口或枚举的实用工具。
v5.2.2
2024-02-13 15:17 UTC
Requires
- php: >=5.4.0
- mvccore/mvccore: ^5.1.0
Requires (Dev)
- php: >=5.4.0
- nette/tester: <=2.4
- tomflidr/tracy: <=2.5.13
README
安装
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();