strikebit / json-to-php
Utility for creating PHP classes from JSON
v1.0.0
2020-03-04 20:30 UTC
Requires
- php: ^7.1.3
Requires (Dev)
- escapestudios/symfony2-coding-standard: ^3.1
- phpmd/phpmd: ^2.6
- sebastian/phpcpd: ^4.0
- squizlabs/php_codesniffer: ^3.0
- symfony/phpunit-bridge: ^4.0
This package is auto-updated.
Last update: 2025-03-05 07:58:41 UTC
README
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.
Installation
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
Usage
Command Line
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)
Contributing
Testing
Apache Ant is required.
ant
Build errors will appear in build/results.