Download the PHP package guuzen/json-schema-codegen without Composer

On this page you can find all versions of the php package guuzen/json-schema-codegen. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-schema-codegen

The Problem

When your application communicates with external systems - APIs, message queues, event streams - you typically define data contracts using JSON Schema. On the PHP side, you represent those contracts as DTO classes with typed properties.

The problem is keeping both in sync. Every time the schema changes, you have to manually update the corresponding PHP class: rename properties, adjust types, add or remove fields. This is repetitive, error-prone, and easy to forget. The schema and the code silently drift apart, and type mismatches only surface at runtime.

The Solution

JSON Schema Codegen generates PHP DTO classes directly from your JSON Schema files. Run the generator after any schema change and your PHP classes are always up to date - no manual editing required.

The generator maps JSON Schema types to precise PHPDoc annotations that static analysis tools like PHPStan understand:

Requirements

Installation

Quick Start

Create a PHP script that configures and runs the generator:

Run it with php generate.php whenever your schemas change.

Configuration

Option Type Description
baseNamespace string Root namespace for all generated classes
schemaPath string Absolute path to the directory containing your schema files
outputPath string Absolute path to the directory where generated PHP files are written
schemaSuffix string File extension used to identify schema files; also selects the decoder (.json or .yaml)
undefinedPath string Schema path (relative to schemaPath) representing an absent value, referenced by non-required properties so absence is distinguishable from null
typeMappings array<string, class-string> Optional. Maps a schema path (relative to schemaPath) to an existing class to reference instead of generating, e.g. ['DateTimeImmutable.json' => DateTimeImmutable::class]

Schema files in subdirectories of schemaPath produce classes in sub-namespaces. For example, schemas/billing/Address.json generates App\Dto\billing\Address.

Example

Given this schema at schemas/Product.json:

The generator produces output/Product.php:

Cross-file references via $ref are also resolved. Given schemas/Order.json:

The generator produces:

YAML Support

YAML schema files are supported out of the box. Install symfony/yaml and set schemaSuffix to .yaml - create() selects the matching decoder from the suffix automatically:

For full control, use NetteFilesGeneratorFactory::assemble(...) directly.

Running Tests


All versions of json-schema-codegen with dependencies

PHP Build Version
Package Version
Requires league/uri Version ^7.8
php Version >=8.4 <8.6
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package guuzen/json-schema-codegen contains the following files

Loading the files please wait ...