A tool to generate PSR-2 compliant PHP model classes from JSON. This tool will recursively inspect JSON and generate corresponding classes complete with getters & setters.
If you're wanting this to be a part of your project:
composer require strikebit/json-to-php
If you're wanting this to be a standalone tool, clone this repository. Then install dependencies:
composer install
Example:
php ./bin/cli.php ./input-file.json User 1 1 Acme\\Entity > output.txt
Arguments:
- Location of your input JSON file.
- Desired class name
- Type hinting (0|1)
- Fluent setters (0|1)
- Desired namespace (optional)
Apache Ant is required.
ant
Build errors will appear in build/results.