File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ <p align =" center " >
2+ <img src="https://joonlabs.com/php-graphql/logo.svg" alt="index.js logo" width="300" align="center" style="width: 300px; display: block; margin-left: auto; margin-right: auto;"/>
3+ </p >
4+
5+ # php-graphql
6+
7+ php-graphql is a pure php implementation of the latest GraphQL [ specification] ( https://github.com/graphql/graphql-spec ) based on the [ reference implementation in JavaScript] ( https://github.com/graphql/graphql-js ) .
8+
9+ ## Installation
10+ ** git clone:**
11+ ```` bash
12+ git clone https://github.com/joonlabs/php-graphql.git
13+ ````
14+ after downloading include the autloader.php, e.g.:
15+ ```` php
16+ require 'php-graphql/src/autoloader.php';
17+ ````
18+ ## Hello world!
19+
20+ ``` php
21+ use GraphQL\Servers\Server;
22+ use GraphQL\Schemas\Schema;
23+ use GraphQL\Types\GraphQLString;
24+ use GraphQL\Types\GraphQLObjectType;
25+ use GraphQL\Fields\GraphQLTypeField;
26+ use GraphQL\Arguments\GraphQLFieldArgument;
27+
28+ // build the query type
29+ $QueryType = new GraphQLObjectType("Query", "Root Query", function (){
30+ return [
31+ new GraphQLTypeField(
32+ "hello",
33+ new GraphQLString(),
34+ "Your first hello world GraphQL-Application",
35+ function (){ return 'Hello world!'; }
36+ )
37+ ];
38+ });
39+
40+ // build the schema
41+ $schema = new Schema($QueryType);
42+
43+ // start a server
44+ $server = new Server($schema);
45+ $server->listen();
46+ ```
47+
48+ That's it! Now the GraphQL server is ready to accept requests at the URL of the PHP script.
49+
50+ ## Backers and sponsors
51+ <img src =" https://joonlabs.com/php-graphql/backers/joon.png " alt =" index.js logo " height =" 30 " /><br >
52+ see [ joonlabs.com] ( https://joonlabs.com )
53+ <br >
54+ <br >
55+ <img src =" https://joonlabs.com/php-graphql/backers/leafx.png " alt =" index.js logo " height =" 30 " /><br >
56+ see [ leafx.de] ( https://leafx.de )
57+ <br >
58+ <br >
You can’t perform that action at this time.
0 commit comments