Download the PHP package snakedove/php-to-typescript-converter without Composer
On this page you can find all versions of the php package snakedove/php-to-typescript-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download snakedove/php-to-typescript-converter
More information about snakedove/php-to-typescript-converter
Files in snakedove/php-to-typescript-converter
Package php-to-typescript-converter
Short Description Converts POPOs to Typescript interfaces.
License MIT
Informations about the package php-to-typescript-converter
README
Thanks for using snakedove/php-to-typescript-converter
!
What is this repository for?
- Adds a command to your symfony project with which you can convert plain old php objects e.g. DTOs to TypeScript Interfaces.
Usage
bin/console ts-create <Source File> <Destination Directory>
creates a Typescript Interface.d.ts file for a given source .php file.
bin/console ts-create-all <Source Directory> <Destination Directory>
creates Typescript Interface files for all source .php files contained in the given directory and its sub-directories, recursively.
- Nullable types will not convert to
type | null
because all types are nullable by default in TypeScript.
Prerequisites
- Works for PHP 7.4 POPOs only
- Works from Symfony 4
Configuration
-
add one or both of the following configuration to your
services.yaml
: -
Now, the command
ts-create
should show up when usingbin/console list
. - Now, the command
ts-create-all
should show up when usingbin/console list
.
Optional:
- pass argument
$nameSuffix
to the command, e.g. 'Interface'. This will add 'Interface' to all file and interface names. - pass argument
$convertCollection
to the command. Set to false, this will include the collection as an own InterfaceType. Per default, collections will be converted toCollectionType[]
, and Collection classes will not be converted.
Example configuration
Caveats
- Does currently not support fluent interfaces