phrity / websocket-graphql
WebSocket GraphQL server
1.0.0
2025-06-25 18:25 UTC
Requires
- php: ^8.1
- phrity/websocket: ^3.0
- webonyx/graphql-php: ^15.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.0 | ^11.0 | ^12.0
- phrity/net-mock: ^2.3
- squizlabs/php_codesniffer: ^3.5
README
Websocket GraphQL Server for PHP
This library provides a GraphQL server over WebSocket.
It connects two popular and well developed libraries to achieve a competent and highly configurable server.
- phrity/websocket for WebSocket server
- webonyx/graphql-php for GraphQL API
Installing
Preferred way to install is with Composer.
composer require phrity/websocket-graphql
Setup
You only need to create a GraphQL server config and add it to the middleware provided by this library.
// Setup GraphQL server configuration with schema etc $serverConfig = GraphQL\Server\ServerConfig::create([ 'schema' => $schema, ]); // Setup WebSocket server with the GraphQL middleware $server = new WebSocket\Server($port, $ssl); $server ->addMiddleware(new WebSocket\Middleware\CloseHandler()) ->addMiddleware(new WebSocket\Middleware\PingResponder()) ->addMiddleware(new Phrity\WebSocket\GraphQL\Middleware($serverConfig)) ; // Run the server - the middleware will respond to requests $server->start();