Symfony bundle for the thecodingmachine/graphqlite package.
It discovers your annotated controllers and types, builds the schema, exposes the /graphql endpoint through a PSR-7
bridge (with optional upload handling), and keeps the Symfony request available as the GraphQL context.
Part of the bundle docs: https://graphqlite.thecodingmachine.io/docs/symfony-bundle
See thecodingmachine/graphqlite.
- PHP 8.1+
- Supports:
- Symfony 6.4/7.0/8.0
- GraphQLite ^8
composer require thecodingmachine/graphqlite-bundleEnsure the bundle is enabled (Symfony Flex does this automatically via config/bundles.php after composer require).
Import the bundle routes to expose /graphql:
# config/routes/graphqlite.yaml
graphqlite_bundle:
resource: '@GraphQLiteBundle/Resources/config/routes.php'Tell GraphQLite where to look for controllers and types:
# config/packages/graphqlite.yaml
graphqlite:
namespace:
controllers: App\\GraphQL\\Controller
types:
- App\\GraphQL\\Type
- App\\EntityCreate a controller with GraphQLite attributes:
<?php
// src/GraphQL/Controller/HelloController.php
namespace App\GraphQL\Controller;
use TheCodingMachine\GraphQLite\Annotations\Query;
final class HelloController
{
#[Query]
public function hello(string $name = 'world'): string
{
return sprintf('Hello %s', $name);
}
}- Auto-discovers controllers and types from configured namespaces and registers GraphQLite services, query providers, type mappers, and middleware through Symfony autoconfiguration
- Ships a
/graphqlroute that converts Symfony requests to PSR-7 and keeps the Symfony request in the GraphQL context - Passes the Symfony request as context to allow using them in queries/mutations
- Supports multipart uploads when
graphql-uploadis installed - Integrates with Symfony Security for
#[Logged]/#[Right]checks - Expose
login/logoutmutations plus amequery (opt-out) - Symfony Validator-based user input validation
- Lets you cap introspection, query depth, and query complexity via configuration
- Uses Symfony cache (APCu or PHP files) for schema caching
- Includes a
graphqlite:dump-schemaconsole command to export GraphQL SDL
The bundle wires Overblog’s GraphiQL bundle if it is installed. See https://github.com/overblog/GraphiQLBundle for
enabling the UI alongside the /graphql endpoint.
- Tests:
vendor/bin/phpunit - Static analysis:
composer phpstan