PHPackages                             plmrlnsnts/typewriter - 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. plmrlnsnts/typewriter

ActiveLibrary[API Development](/categories/api)

plmrlnsnts/typewriter
=====================

A tool for generating PHP code based on a GraphQL schema and GraphQL operations.

v0.0.3(today)31MITPHPPHP ^8.3CI passing

Since Mar 20Pushed todayCompare

[ Source](https://github.com/plmrlnsnts/typewriter)[ Packagist](https://packagist.org/packages/plmrlnsnts/typewriter)[ RSS](/packages/plmrlnsnts-typewriter/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

⌨️ Typewriter
=============

[](#️-typewriter)

Typewriter is a GraphQL code generation tool to easily generate PHP classes and enums from your GraphQL schema and GraphQL operations.

```
vendor/bin/typewriter
```

Features
--------

[](#features)

- Converts GraphQL schemas and operations into strongly-typed PHP code
- Generates classes, enums, and input types for your GraphQL client
- Supports custom type casting and namespace organization
- Automates code generation for GraphQL queries

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

[](#installation)

```
composer require --dev plmrlnsnts/typewriter

vendor/bin/typewriter init
```

Configuration
-------------

[](#configuration)

After installation, a `typewriter.json` configuration file is created in your project root.

```
{
  "schemas": [
    {
      "source": "schema.json",
      "enums": {
        "directory": "app/Graphql/Enums",
        "namespace": "App\\Graphql\\Enums"
      },
      "inputs": {
        "directory": "app/Graphql/Inputs",
        "namespace": "App\\Graphql\\Inputs"
      },
      "entrypoints": [
        {
          "input": "app",
          "output": "app/Graphql/Data",
          "namespace": "App\\Graphql\\Data"
        }
      ]
    }
  ]
}
```

### Available Options

[](#available-options)

- **schemas**: List of schema configurations. Each object describes how to generate code for a GraphQL schema.
    - **source**: Path to your GraphQL introspection JSON file (e.g., `schema.json`).
    - **enums**: Where to generate PHP enums.
        - **directory**: Output directory for generated enum classes.
        - **namespace**: PHP namespace for generated enums.
    - **inputs**: Where to generate PHP input classes.
        - **directory**: Output directory for generated input classes.
        - **namespace**: PHP namespace for generated inputs.
    - **entrypoints**: List of entrypoints for code generation. Each entrypoint defines a set of GraphQL operations to generate code for.
        - **input**: Directory or file containing GraphQL operation documents (e.g., queries, mutations).
        - **output**: Output directory for generated data classes.
        - **namespace**: PHP namespace for generated data classes.

### Custom Casts

[](#custom-casts)

You can customize how GraphQL scalar types are mapped to PHP types or classes by using the `casts` option in your schema configuration. This is useful when you want to use custom value objects, type wrappers, or specific PHP classes for certain GraphQL scalars (e.g., mapping `DateTime` to a custom `DateTime` class instead of a string).

Add a `casts` object inside your schema configuration, where each key is a GraphQL scalar type and each value is the fully qualified PHP class name to use for that type.

```
{
  "casts": {
    "DateTime": "App\\Graphql\\Casts\\DateTime",
    "ID": "App\\Graphql\\Casts\\Identity"
  }
}
```

### Extending Types

[](#extending-types)

You can customize the base class that all generated types will extend by specifying the `type` option in your schema configuration. By default, generated classes extend the built-in `Plmrlnsnts\Typewriter\Type`, but you may want to use your own. For example, using [spatie/laravel-data](https://github.com/spatie/laravel-data):

```
{
  "type": "Spatie\\LaravelData\\Data"
}
```

### Downloading schema.json

[](#downloading-schemajson)

To generate a `schema.json` from your GraphQL endpoint, you can use [get-graphql-schema](https://github.com/prisma-labs/get-graphql-schema) or similar tools.

```
npm install -g get-graphql-schema

get-graphql-schema https://your.graphql.endpoint > schema.json
```

Author
------

[](#author)

Paul Santos

###  Health Score

39

—

LowBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~0 days

Total

3

Last Release

0d ago

PHP version history (2 changes)0.0.1PHP &gt;=8.4.1

v0.0.2PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/32bd66c0f2d7daaf80938a7c11063fd243a4ac7b6c75f21dc85015664dccc8d1?d=identicon)[plmrlnsnts](/maintainers/plmrlnsnts)

---

Top Contributors

[![plmrlnsnts](https://avatars.githubusercontent.com/u/16243345?v=4)](https://github.com/plmrlnsnts "plmrlnsnts (9 commits)")

---

Tags

codegengraphqlphp

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/plmrlnsnts-typewriter/health.svg)

```
[![Health](https://phpackages.com/badges/plmrlnsnts-typewriter/health.svg)](https://phpackages.com/packages/plmrlnsnts-typewriter)
```

###  Alternatives

[nuwave/lighthouse

A framework for serving GraphQL from Laravel

3.5k10.4M77](/packages/nuwave-lighthouse)[wp-graphql/wp-graphql

GraphQL API for WordPress

3.8k385.2k16](/packages/wp-graphql-wp-graphql)[overblog/graphql-bundle

This bundle provides tools to build a GraphQL server in your Symfony App.

7967.7M22](/packages/overblog-graphql-bundle)[thecodingmachine/graphqlite

Write your GraphQL queries in simple to write controllers (using webonyx/graphql-php).

5693.0M24](/packages/thecodingmachine-graphqlite)[mll-lab/graphql-php-scalars

A collection of custom scalar types for usage with https://github.com/webonyx/graphql-php

1474.1M18](/packages/mll-lab-graphql-php-scalars)[aimeos/ai-admin-graphql

Aimeos Admin GraphQL API extension

93997.0k3](/packages/aimeos-ai-admin-graphql)

PHPackages © 2026

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