mmouih / entity-generator
A tool designed to streamline the conversion of payloads (json, xml or yaml) into class entities
Requires
- nette/php-generator: ^4.1
- nikic/php-parser: ^4.17
- symfony/cache: ^6.3
- symfony/config: ^6.3
- symfony/console: ^6.3
- symfony/dependency-injection: ^6.3
- symfony/error-handler: ^6.3
- symfony/finder: ^6.3
- symfony/http-kernel: ^6.3
- symfony/property-access: ^6.3
- symfony/runtime: ^6.3
- symfony/serializer: ^6.3
- symfony/string: ^6.3
- symfony/var-dumper: ^6.3
- symfony/yaml: ^6.3
Requires (Dev)
- phpstan/phpstan: ^1.10
- squizlabs/php_codesniffer: ^3
- symfony/test-pack: ^1.0
This package is auto-updated.
Last update: 2024-04-27 02:06:11 UTC
README
The Entity Generator is a tool designed to streamline the conversion of payloads into class entities for PHP applications running on PHP 7 and beyond. The generated entities adhere to the PSR-12 coding standards, ensuring a clean and consistent codebase.
This tool is particularly valuable for swiftly transforming payloads into Data Transfer Objects (DTOs), enhancing your PHP application's flexibility and efficiency.
Requirements
- PHP 8.2 or higher
Usage
To leverage the Entity Generator, use the following command:
Using Json file
./phpgen generate [EntityName] [Payload] --f
Using Json string
./phpgen generate [EntityName] [Json] "json"
Or simply
./phpgen generate [EntityName] [Json]
Example:
./phpgen generate User '{"id": 1, "label": "john"}'
Using XML file
./phpgen generate [EntityName] [filepath] "xml" -f
Using XML string
./phpgen generate [EntityName] [XML] "xml"
Using Yaml file
./phpgen generate [EntityName] [filepath] "xml" -f
Configuration file
You can use customized entity generation options using a configuration a below,
#config.yaml.dist entity.generator: output.dir: 'var/generated' namespace: 'Entity\Generated' property.phpdoc: true property.type: true # false before php7.4
./phpgen generate [EntityName] [filepath] "xml" -f -c path/to/config.yaml.dist
If config file is not configured, default options (config.yaml.dist)
will be used.