composer require mvccore/ext-tool-ts-generator
Extension to easilly generate TypeScript model classes, interfaces or enums from PHP equivalents.
<?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();