1. Go to this page and download the library: Download k-adam/entity-transpiler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
k-adam / entity-transpiler example snippets
use EntityTranspiler\Annotations as ET;
/**
* @ET\Entity
*/
class User {
/**
* @ET\Property(type="int")
*/
private $id;
/**
* @ET\Property(type="string")
*/
private $name;
}
use EntityTranspiler\Generators\Utils\ClassResolver\PathResolver;
use EntityTranspiler\Utils\ClassRef\Transformer;
use EntityTranspiler\Utils\NameFormat\Writer;
return [
// Location of your php entity classes
"sourceExplorer"=>[
"class" => \EntityTranspiler\SourceExplorers\ClassFinder::class,
"config" => ["path"=>"src"]
],
// Use docblock annotations, to define entities and properties
"loader"=>[
"class" => \EntityTranspiler\Loaders\Annotation::class,
"config" => []
],
// Export options
"generator"=>[
// Generate typescript classes
"class" => \EntityTranspiler\Generators\Typescript::class,
"config" => [
// Define associations between source namespace+class names, and the target namespace+class names
// Multiple resolve rules can be defined, with different sources
"classResolver" => [
[
// Filter source namespace/class
// "source" => "App\\*"
"source" => "*",
// Output options
"pathResolver" => [
"type" => PathResolver::TYPE_DIRECTORY,
"path" => "output",
"dirNameFormat" => Writer::KEBAB_CASE,
"fileNameFormat" => Writer::KEBAB_CASE
],
// Class/enum name format
"classNameResolver" => ["format"=>Writer::PASCAL_CASE],
"enumResolver" => ["propertyNameFormat"=>Writer::PASCAL_CASE],
// Transform namespace+class names before export
"transformer" => [
"type" => Transformer::TYPE_COMPOSITION,
"transformers" => [
[
// Skip top level ( App ) namespace in path
"type" => Transformer::TYPE_SLICE_NAMESPACE,
"offset" => 1
],
[
// Keep the currently top level namespaces: Shop/Ticketing (offset:1)
// Concatenate the subnamespaces with the classnames ( Shop\Cart\Entry -> Shop\CartEntry )
"type" => Transformer::TYPE_PREPEND_NAMESPACE,
"offset" => 1
]
]
]
]
]
]
]
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.