State of GraphQL PHP libraries and Symfony integrations in 2017
Creating a GraphQL compliant server implementation is not a trivial task and it is not advisable to create your own from scratch for any language. For PHP there are currently two libraries that offer solid base to build GraphQL implementations on top of:
Both of these libraries provide a PHP port based on the Reference GraphQL implementation written in JavaScript. Functionally neither of these options are superior, and the basic principle is the same; to offer a framework to set up types, resolving, etc. that works according to the GraphQL specification.
Both the Webonyx and Youshido libraries are being actively developed, and have a relatively large contributor number of 28 and 32 respectively. With the GraphQL specification now stable and the implementations very feature complete, there is not a lot of significant work that is being done to these libraries.
Symfony GraphQL integration Bundles
The Webonyx library and Youshido libraries also have integrations to the Symfony Framework. Like the libraries themselves, both Bundles are virtually identical in functionality; they integrate the underlying library to the framework configuration methods, access to the GraphiQL client, etc. They let developers get a headstart and start defining configurations and developing their resolvers, instead of boilerplating framework integration.
For the Youshido GraphQL integration bundle comes from the same team of developers as the library itself. The Symfony Bundle is straightforward to integrate, is well documented and comes with an example demo app implementation. It's also worth noting that the Drupal 8 GraphQL module is using the Youshido library under the hood.
The GraphQL integration Bundle for the Webonyx library is from a separate team than the library is. The integration bundle is developer by Overblog, a blogging platform from France. Like the Youshido framework, the bundle integrates the library to the framework. The documentation has improved lately, but a demo implementation would help new developers get started faster.
Conclusion
Developers with existing or new PHP applications now have two solid options for building GraphQL implementations on top of. Both Webonyx and Youshido libraries are good options, and seem to have a stable future with widespread use.
For Symfony developers the same is true, both libraries have a high quality integration to the framework. Both options are great, but what might be a deciding factor currently is whether you are using the Symfony Standard Edition or Symfony Flex.
The Overblog integration has already started to focus on Symfony Flex, while the Youshido team has not yet taken any steps towards supporting Flex officially.
Learn more about GraphQL:
- What is GraphQL and how does it differ from REST APIs?
- A GraphQL Bundle adds protocol support to eZ Platform Symfony CMS
- Building Decoupled Sites and Apps with GraphQL and Next.js
- Tom Dale on GraphQL, Relay and REST