php-graphql is a pure php implementation of the latest GraphQL specification based on the reference implementation in JavaScript.
git clone:
git clone https://github.com/joonlabs/php-graphql.gitafter downloading include the autloader.php, e.g.:
require 'php-graphql/src/autoloader.php';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.
![]()
see joonlabs.com
![]()
see leafx.de