Skip to content

joonlabs/php-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

index.js logo

php-graphql

php-graphql is a pure php implementation of the latest GraphQL specification based on the reference implementation in JavaScript.

Installation

git clone:

git clone https://github.com/joonlabs/php-graphql.git

after downloading include the autloader.php, e.g.:

require 'php-graphql/src/autoloader.php';

Hello world!

use GraphQL\Servers\Server; use GraphQL\Schemas\Schema; use GraphQL\Types\GraphQLString; use GraphQL\Types\GraphQLObjectType; use GraphQL\Fields\GraphQLTypeField; use GraphQL\Arguments\GraphQLFieldArgument; // build the query type $QueryType = new GraphQLObjectType("Query", "Root Query", function (){ return [ new GraphQLTypeField( "hello", new GraphQLString(), "Your first hello world GraphQL-Application", function (){ return 'Hello world!'; } ) ]; }); // build the schema $schema = new Schema($QueryType); // start a server $server = new Server($schema); $server->listen();

That's it! Now the GraphQL server is ready to accept requests at the URL of the PHP script.

Backers and sponsors

index.js logo
see joonlabs.com

index.js logo
see leafx.de