React, etc. Tech Stack

React, Flux, GraphQL, Hack, HHVM...? All of this and more!

What is the best GraphQL library for PHP in 2019?

The GraphQL momentum has continued strong throughout 2018. After three years of being released as open source by the dev team at Facebook, the protocol is now nearly ubiquitious.

The reference implementation of GraphQL is written in JavaScript, and thus it makes sense to use this as the de-facto standard in projects. However, for PHP developers it is not always as clear.

As with any open standard, it is never recommended to roll your own library implementation. GraphQL backends are not simple to create, and always solve the same problem. This means you rolling your own GraphQL implementation should be the last thing on your mind.

As for available libraries, there are many options on the market for GraphQL implementations for PHP developers. Two of the most common ones are already longstanding and mature:

These options and their advantages and disadvantages have been covered extensively recently: State of GraphQL PHP libraries and Symfony integrations in 2017

A modern GraphQL library for PHP 7.1+

With PHP 7.3 the PHP 7 series is now in it's fourth feature release. While many older generation applications like WordPress continue to support the, now unsupported 5 series, the world needs to move on and embrace the improvements in the language.

As for GraphQL libraries, both the WebOnyx and Youshido libraries continue evolve. They have integrations to popular frameworks like Laravel and Symfony. However, there is always room for challengers. And especially ones that leverage the most common available improvements from the PHP runtime.

One such library newly made available is the DigiaOnline GraphQL library of PHP. This new library is a fresh implementation of the specification, written in contemporary PHP. The library requires PHP 7.1 or higher, and makes no compromise for backwards compatibility for PHP 5.x or similar.

The project is MIT licensed, and at heart graphql-php is an implementation of the GraphQL specification based on the JavaScript reference implementation and even sports a simple Laravel GraphQL integration example out of the box.

So in 2019 PHP developers wishing to leverage GraphQL in their applications, should take a hard look at three options in the ecosystem for GraphQL libraries and consider which is optimal for their use case and coding style.

Written by Jorgé on Friday October 19, 2018

Permalink -

« Vulnerabilities in elevator control system disclosed - The future of PHP 8 unclear »