PHPackages                             kronostechnologies/graphql-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kronostechnologies/graphql-generator

AbandonedArchivedLibrary[API Development](/categories/api)

kronostechnologies/graphql-generator
====================================

GraphQL classes generator based on Webonyx library

v0.3.3(7y ago)0601MITPHP

Since May 9Pushed 7y ago16 watchersCompare

[ Source](https://github.com/kronostechnologies/graphql-generator)[ Packagist](https://packagist.org/packages/kronostechnologies/graphql-generator)[ RSS](/packages/kronostechnologies-graphql-generator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (10)Used By (0)

graphql-generator
=================

[](#graphql-generator)

[![CircleCI](https://camo.githubusercontent.com/90fc9c2d48eb32d1af03d27dd924e48aaf64f72e238e1ffa84bf9c9d1781d2fc/68747470733a2f2f636972636c6563692e636f6d2f67682f6b726f6e6f73746563686e6f6c6f676965732f6772617068716c2d67656e657261746f722e7376673f7374796c653d737667)](https://circleci.com/gh/kronostechnologies/graphql-generator)[![Coverage Status](https://camo.githubusercontent.com/4e46666674c51a15326b3bf75afa78f12b5ad9f28e7feb5d7c289c042416ba21/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6b726f6e6f73746563686e6f6c6f676965732f6772617068716c2d67656e657261746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/kronostechnologies/graphql-generator?branch=master)

Converts a GraphQL Schema to static PHP files. It currently supports generating namespaced class file. The tool is interfaced through a CLI.

Requirements
------------

[](#requirements)

- **PHP 5.6** or higher.
- Composer

Installation
------------

[](#installation)

The repository can be cloned in order to gain access to the GraphQL generator.

```
git clone https://github.com/kronostechnologies/graphql-generator.git
composer install

```

Examples
--------

[](#examples)

The [examples](./examples) source directory contains some graphqls schema examples on which you can run the tool against.

### Simple schema generation

[](#simple-schema-generation)

To generate class files from a valid graphqls file, run the following command:

```
php graphqlgen generate-classes ./examples/base.graphqls ./base

```

The output files will appear in the `base` directory.

Testing
-------

[](#testing)

Run unit tests with PHPUnit 5.7.

```
phpunit

```

Usage
-----

[](#usage)

You can run the CLI tool with the following command:

```
php graphqlgen generate-classes [options] [--]

```

Arguments are:

- *input*: A .graphqls file to use as input.
- *targetdir*: A directory in which to generate the classes.

Available options are:

- `--writer=WRITER`: Type of writer with which to output the files. Default is namespaced.
    - Namespaced Writer: A class will be generated for each type definition under `Types\Enums` for enum types, `Types\Input` for input types, `Types\Interfaces` for interface types, `Types\Scalars` for scalar types, `Types\Unions` for union types, and `Types` for standard types. Per-directory namespacing standard will be respected.
- `--stubs-dir`: This is a directory containing the stub files.
- `--overwrite`: If this flag is set, the writer will attempt to override the files. If not, a warning will be thrown when an existing file is found.
- `--formatter-use-tabs`: If this flag is set, the PHP ouput file formatter will use tabs instead of spaces for indentation.
- `--formatter-indent-spaces`: If not using tabs for the formatter, this is the number of spaces per indent block. Default is 4.
- `--formatter-line-merge`: When descriptions are written on multiple lines in a .graphqls file, they are merged with the specified character. Default is `,`.

### Namespaced Writer

[](#namespaced-writer)

Although the namespaced writer is currently the only writer supported, it comes with a few options bundled:

- `--namespaced-target-namespace`: If using the namespaced Writer, the given namespace will be prefixed. This does not alter the target directory structure.

#### Additional files

[](#additional-files)

In addition to generating the type definitions for each type, the following files are generated.

All types are statically initialized in the *TypeStore*. This helps ensure only a single instance of a type definition throughout the application. The properties of each type are stored independently in a *DTO*.

TypeStore location:

```
\TypeStore

```

For *input* types, and *Union* types, a *resolver* is created. This file is intended to be editable by the user of this tool, and to split the type definition from the actual code. The resolvers are initialized through the `ResolverFactory`. This allows passing external values to the resolvers constructors.

Resolvers namespace format:

```
Resolvers\Types\[TypeCategory]\TypeName

```

Additionally, for *input* types, a *DTO* is created. DTO serve as a data structure that should ultimately be returned by the resolver functions. It is important to separate these concerns as a type definition can only exist once (hence the need of a TypeStore), but a DTO can exist multiple times throughout the application.

DTO namespace format:

```
DTO\Types\[TypeCategory]\TypeName

```

*Interfaces* use composition instead of inheritance due to GraphQL being able to implement multiple of them. They are declared in two components: a trait, and a bare class implementing this trait. The trait contains all members.

#### Stub Files

[](#stub-files)

The stub files are used as a boilerplate for generating the files of a specific GraphQL type. For the namespaced Writer, the files required are the same ones in [src/Generator/Writer/Namespaced/stubs](./src/Generator/Writer/Namespaced/stubs).

For example, an interface type will use `interface.stub` as its base file for generating the class. The following types are matched:

- Enums: `enum.stub`
- Interfaces: `interface.stub`
- Inputs: `input.stub`
- Object: `object.stub`
- Scalar: `scalar.stub`
- Unions: `union.stub`

Additionally, `typestore.stub` is matched to the `TypeStore`, `dto.stub` to DTOs, and `resolver.stub` to resolvers.

See [src/Generator/Writer/Namespaced/stubs](./src/Generator/Writer/Namespaced/stubs) for the stub files content.

Mutations
---------

[](#mutations)

Mutations are currently ignored when generating the GraphQL files. As these mostly imply logical operations, you will need to implement the resolve functions yourself.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~101 days

Total

7

Last Release

2885d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/24f93af7d1b960ef7712399ef02cc1450dc4a13073fdba180789e58edbeccee1?d=identicon)[ma-boily](/maintainers/ma-boily)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kronostechnologies-graphql-generator/health.svg)

```
[![Health](https://phpackages.com/badges/kronostechnologies-graphql-generator/health.svg)](https://phpackages.com/packages/kronostechnologies-graphql-generator)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[worksome/graphlint

A static analysis tool for GraphQL

13189.4k](/packages/worksome-graphlint)[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

632.3k](/packages/rubix-server)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
