PHPackages                             mathsgod/light-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. mathsgod/light-graphql

ActiveLibrary[API Development](/categories/api)

mathsgod/light-graphql
======================

Simple graphql server

v1.3.0(1mo ago)01671MITPHPPHP ^8.3

Since Mar 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/mathsgod/light-graphql)[ Packagist](https://packagist.org/packages/mathsgod/light-graphql)[ RSS](/packages/mathsgod-light-graphql/feed)WikiDiscussions main Synced yesterday

READMEChangelog (6)Dependencies (13)Versions (7)Used By (1)

Light GraphQL
=============

[](#light-graphql)

A lightweight GraphQL server library for PHP 8.3+, built on top of [`thecodingmachine/graphqlite`](https://graphqlite.thecodingmachine.com/).

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

[](#requirements)

- PHP 8.3+

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

[](#installation)

```
composer require mathsgod/light-graphql
```

Dependencies
------------

[](#dependencies)

PackagePurpose`thecodingmachine/graphqlite`GraphQL schema generation via PHP attributes`league/container`Dependency injection container`symfony/cache`Schema caching`ecodev/graphql-upload`File upload support (multipart/form-data)`laminas/laminas-diactoros`PSR-7 HTTP request/responseUsage
-----

[](#usage)

### Define a Controller

[](#define-a-controller)

Use `#[Query]` and `#[Mutation]` attributes from GraphQLite to define your GraphQL fields:

```
namespace Controllers;

use TheCodingMachine\GraphQLite\Annotations\Query;

class UserController
{
    #[Query]
    public function hello(): string
    {
        return 'world';
    }
}
```

### Execute a Query Directly

[](#execute-a-query-directly)

```
require_once __DIR__ . '/vendor/autoload.php';

$server = new \Light\GraphQL\Server();
$server->getSchemaFactory()->addNamespace('Controllers');

$result = $server->executeQuery('{ hello }');
print_r($result->toArray());
```

### Handle a PSR-7 Request

[](#handle-a-psr-7-request)

`Server` implements `Psr\Http\Server\RequestHandlerInterface` and supports both `application/json` and `multipart/form-data` (file uploads):

```
$server = new \Light\GraphQL\Server();
$server->getSchemaFactory()->addNamespace('Controllers');

// $request is a PSR-7 ServerRequestInterface
$response = $server->handle($request);
```

### Constructor Options

[](#constructor-options)

```
$server = new \Light\GraphQL\Server(
    defaultLifetime: 15,   // Schema cache TTL in seconds (default: 15)
    debug: false,          // Enable debug mode (default: false)
    container: null        // Custom PSR-11 container (default: League\Container)
);
```

#### Debug Mode

[](#debug-mode)

When `debug: true`, error responses include the exception message and stack trace in the `extensions` field:

```
{
  "errors": [
    {
      "message": "Something went wrong",
      "extensions": {
        "trace": [...]
      }
    }
  ]
}
```

### Error Responses

[](#error-responses)

All responses follow the standard GraphQL error format and always return HTTP 200:

```
{
  "errors": [
    { "message": "..." }
  ]
}
```

API
---

[](#api)

MethodDescription`getSchemaFactory(): SchemaFactory`Returns the GraphQLite SchemaFactory for adding namespaces`getContainer(): ContainerInterface`Returns the DI container`getCache(): CacheInterface`Returns the PSR-16 cache instance`executeQuery(?string $query, array $variables, ?string $operationName): ExecutionResult`Execute a GraphQL query directly`handle(ServerRequestInterface $request): ResponseInterface`Handle a PSR-7 HTTP request`executeGraphQLRequest(ServerRequestInterface $request): ResponseInterface`Process a pre-parsed PSR-7 request (used internally by `handle()`)

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance92

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

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

Recently: every ~108 days

Total

6

Last Release

38d ago

PHP version history (2 changes)1.0.0PHP ^8.1

v1.3.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/18732337?v=4)[Raymond](/maintainers/mathsgod)[@mathsgod](https://github.com/mathsgod)

---

Top Contributors

[![mathsgod](https://avatars.githubusercontent.com/u/18732337?v=4)](https://github.com/mathsgod "mathsgod (32 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mathsgod-light-graphql/health.svg)

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

###  Alternatives

[oxid-esales/graphql-base

OXID eSales GraphQL base module

24107.6k16](/packages/oxid-esales-graphql-base)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[whatsdiff/whatsdiff

See what's changed in your project's dependencies

771.2k](/packages/whatsdiff-whatsdiff)[thecodingmachine/graphqlite-bundle

A Symfony bundle for thecodingmachine/graphqlite.

371.7M3](/packages/thecodingmachine-graphqlite-bundle)

PHPackages © 2026

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