mpmontanez / json-schema-to-php-generator
Code generation tool for converting JSON schema documents to simple PHP classes.
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Package info
github.com/mpmontanez/json-schema-to-php-generator
pkg:composer/mpmontanez/json-schema-to-php-generator
Requires
- gossi/php-code-generator: ~0
- league/flysystem: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2026-03-15 03:51:10 UTC
README
Objective: build a code generation tool that will convert JSON spec files into simple PHP classes. Java inspiration: https://github.com/joelittlejohn/jsonschema2pojo
Demo
Generate sample generated-code by executing the following:
php cli/generate.php
The schema source directory will be the 'json-schemas' folder and the code will be placed in the 'generated-code' folder.
Installation
{
"require": {
"mpmontanez/json-schema-to-php-generator": "dev-master"
}
}
Usage
To generate PHP code from a set of JSON schema files, provide the following paramters to the Generator: the base working directory, the JSON schema source folder name, the generated code destination folder name, and the base namespace to use for the generated PHP classes.
BEWARE The initial contents of the destination folder will be deleted when calling generate().
$generator = new \mpmontanez\JsonSchemaToPhpGenerator\Generator(
__DIR__ . '/../', 'json-schemas', 'generated-code', 'Sample\\GeneratedCode\\');
$generator->generate();