PHPackages                             tina4stack/tina4php-graphql - 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. tina4stack/tina4php-graphql

ActiveLibrary[API Development](/categories/api)

tina4stack/tina4php-graphql
===========================

Lightweight GraphQL engine for Tina4 PHP — recursive descent parser, executor, auto-schema from ORM

v2.0.1(3mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Mar 14Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/tina4stack/tina4php-graphql)[ Packagist](https://packagist.org/packages/tina4stack/tina4php-graphql)[ RSS](/packages/tina4stack-tina4php-graphql/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

tina4php-graphql
================

[](#tina4php-graphql)

Lightweight GraphQL engine for the Tina4 PHP framework. Built from scratch with no external dependencies — recursive descent parser, depth-first executor, and auto-schema generation from ORM objects.

[![Tests](https://github.com/tina4stack/tina4php-graphql/actions/workflows/tests.yml/badge.svg)](https://github.com/tina4stack/tina4php-graphql/actions/workflows/tests.yml)

Installing
----------

[](#installing)

```
composer require tina4stack/tina4php-graphql
```

### Requirements

[](#requirements)

- PHP &gt;= 8.1

Usage
-----

[](#usage)

### Simple Queries

[](#simple-queries)

```
$schema = new \Tina4\GraphQLSchema();

$schema->addQuery('hello', [
    'type' => 'String',
    'resolve' => fn() => 'Hello World!',
]);

$schema->addQuery('user', [
    'type' => 'User',
    'args' => ['id' => ['type' => 'ID']],
    'resolve' => fn($root, $args) => ['id' => $args['id'], 'name' => 'Andre'],
]);

$graphql = new \Tina4\GraphQL($schema);
$result = $graphql->execute('{ hello user(id: 1) { name } }');
// $result = ['data' => ['hello' => 'Hello World!', 'user' => ['name' => 'Andre']]]
```

### Auto-Schema from ORM

[](#auto-schema-from-orm)

The killer feature — register ORM classes and get full CRUD automatically:

```
$schema = new \Tina4\GraphQLSchema();
$schema->fromORM(Customer::class);
$schema->fromORM(Order::class);

// Generates automatically:
// Queries:  customer(id), customers(limit, offset)
// Mutations: createCustomer(input), updateCustomer(id, input), deleteCustomer(id)
```

### Tina4 Route Integration

[](#tina4-route-integration)

```
$schema = new \Tina4\GraphQLSchema();
$schema->fromORM(Customer::class);
\Tina4\GraphQLRoute::register($schema);

// POST /graphql with JSON body:
// { "query": "{ customers(limit: 10) { id name email } }" }
```

### Mutations

[](#mutations)

```
$schema->addMutation('createUser', [
    'type' => 'User',
    'args' => ['name' => ['type' => 'String!'], 'email' => ['type' => 'String!']],
    'resolve' => function ($root, $args) {
        $user = new User();
        $user->name = $args['name'];
        $user->email = $args['email'];
        $user->save();
        return ['id' => $user->id, 'name' => $user->name, 'email' => $user->email];
    },
]);
```

### Variables

[](#variables)

```
query GetUser($id: ID!) {
    user(id: $id) {
        name
        email
    }
}
```

```
$result = $graphql->execute($query, ['id' => 42]);
```

### Fragments

[](#fragments)

```
fragment UserFields on User {
    id
    name
    email
}

{
    users {
        ...UserFields
    }
}
```

### HTTP Handler

[](#http-handler)

```
$graphql = new \Tina4\GraphQL($schema);
$jsonResponse = $graphql->handleRequest(file_get_contents('php://input'));
```

Architecture
------------

[](#architecture)

ClassPurpose`GraphQL`Main entry — parse, execute, return result`GraphQLParser`Recursive descent parser — query string to AST`GraphQLExecutor`Walks AST, calls resolvers, builds response`GraphQLSchema`Type definitions, query/mutation registry`GraphQLType`Type system — scalars, objects, lists, non-null`GraphQLRoute`Register `/graphql` POST endpoint in Tina4Supported Features
------------------

[](#supported-features)

- Queries and mutations
- Nested field resolution
- Arguments (string, int, float, boolean, enum)
- Variable definitions and resolution
- Fragment definitions and spreads
- Aliases
- Comments
- List types
- Error collection (non-halting)
- Auto-schema from Tina4 ORM

Running Tests
-------------

[](#running-tests)

```
composer test
```

---

Our Sponsors
------------

[](#our-sponsors)

**Sponsored with 🩵 by Code Infinity**

[![Code Infinity](https://camo.githubusercontent.com/1516fb1662e3486bce77822177a5ea199edc32ea109369812592ec9bca38159a/68747470733a2f2f636f6465696e66696e6974792e636f2e7a612f77702d636f6e74656e742f75706c6f6164732f323032352f30392f6338652d6c6f676f2d6769746875622e706e67)](https://codeinfinity.co.za/about-open-source-policy?utm_source=github&utm_medium=website&utm_campaign=opensource_campaign&utm_id=opensource)

*Supporting open source communities • Innovate • Code • Empower*

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance81

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

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

2

Last Release

100d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/82961293?v=4)[Tina4](/maintainers/tina4stack)[@tina4stack](https://github.com/tina4stack)

---

Top Contributors

[![andrevanzuydam](https://avatars.githubusercontent.com/u/6102941?v=4)](https://github.com/andrevanzuydam "andrevanzuydam (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tina4stack-tina4php-graphql/health.svg)

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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