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(1mo ago)31MITPHPPHP ^8.3CI passing

Since Mar 20Pushed 1mo agoCompare

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

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 85% of packages

Maintenance97

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

49d 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.7M93](/packages/nuwave-lighthouse)[thecodingmachine/graphqlite

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

5723.1M30](/packages/thecodingmachine-graphqlite)[overblog/graphql-bundle

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

8027.9M28](/packages/overblog-graphql-bundle)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[aimeos/ai-admin-graphql

Aimeos Admin GraphQL API extension

944100.0k4](/packages/aimeos-ai-admin-graphql)[mll-lab/graphql-php-scalars

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

1394.2M28](/packages/mll-lab-graphql-php-scalars)

PHPackages © 2026

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