知海

PHP:Siler(服务端)

graphql-github-io-zh-Hans生态项目与库

PHP:Siler(服务端)

属性
名称 Siler
描述 Siler 是一个使用高阶抽象来处理 GraphQL 的 PHP 库。
官网 https://siler.leocavalcante.com/graphql/
GitHub leocavalcante/siler

要运行 Siler 的 hello world 脚本:

graphql 复制代码
type Query {
  hello: String
}
php 复制代码
<?php
declare(strict_types=1);
require_once '/path/to/vendor/autoload.php';

use SilerDiactoros;
use SilerGraphql;
use SilerHttp;

$typeDefs = file_get_contents(__DIR__.'/schema.graphql');
$resolvers = [
    'Query' => [
        'hello' => 'world',
    ],
];
$schema = Graphqlschema($typeDefs, $resolvers);

echo "Server running at http://127.0.0.1:8080";

Httpserver(Graphqlpsr7($schema), function (Throwable $err) {
    var_dump($err);
    return Diactorosjson([
        'error'   => true,
        'message' => $err->getMessage(),
    ]);
})()->run();

它还提供了基于 Apollo 的工作方式构建 WebSocket 订阅服务器(Subscriptions Server)的功能。

帮助我们改进文档

发现翻译问题或内容错误?请告诉我们。