Skip to content
Insights

Advanced Serializing in PHP

keynote

Michelle got the honours of having one of the first 3 tracks after Cal Evans his key note. She talked about her bumpy ride into serializing data and how she and her team came up with the perfect solution for their project.
For those not familiar with the concept, serializing is transforming your data into a request output format such as JSON or XML and deserialization the other way around.

Symfony serializer

Performance issues

For a big retailer in Switzerland, Michelle used the familiar JMS serializer. This turned out to be a bottleneck in their application for years as they experienced performance issues. Michelle explained the road towards their solution which resulted in a 55% overall performance gain.

To find this bottleneck, Blackfire was used. Left you see a screenshot of a JMS method being called 60.000 times in a single call.

JMS Serializer blackfire

Solutions?

A lot of solutions were tried: JMSSymfony serializer, Better serializer and lots of other PHP serializers. All of them are great libraries, but none of them showed any improvements. By that time the team accepted to live with this performance hit until a new GoLang developer joined.
He worked on a solution in GoLang: Sheriff. The first results were very promising. To reuse the current JMS annotations Liip created a library for generating Go structs using Sheriff out of PHP models. And at last, to make things work with the PHP application, Goridge was used. Goridge allows you to call Go service methods from PHP.

This GO + PHP approach was great and the application had a huge speed boost. But, PHP had no fair chance. So the team decided to implement the way GO uses serialization into their own open source php library: liip/serializer.

liip/serializer

This open source library generates PHP code based on the PHP models that you specify. A separate file is generated for every version and serializer groups combination to move all logic to the code generation step. Note, they use twig to generate PHP files! By generating these files up front they speed the application. It works the same as JMS, so it should be easy to replace.

Thoughts

Always educative to hear how others approach the issues they encounter. In my opinion it could go a bit deeper into the serializer and what exactly made the improvements as that part was very interesting.

More insights

  • Stronger united: Lunar and Codana merge into one brand

    Stronger united: Lunar and Codana merge into one brand
  • Cross-platform applicaties with React Native

    Never before has developing native mobile applications been as accessible as it is today. At Codana, we do this by using the React Native, an open-source framework developed by Meta.

    Cross-platform applicaties with React Native
  • Laracon EU 2024

    A fantastic learning experience to inspire and be inspired together with a lot of other Laravel passionate people! Something we couldn't miss and very much connect with the community. What a top event! Who will we see next editions? 😮

    Laracon EU 2024
  • An efficient tourism data management system | Codana

    A TDMS or Tourist Data Management System, is simply a platform that retrieves data from various sources, processes it internally either automatically or not, and offers this data back to external platforms.

    An efficient tourism data management system | Codana
  • Tourism Data Management Systems

    In this article, we explore what a TDMS is, why it is essential for the tourism industry, and how technologies like Laravel and ElasticSearch can make a difference.

    Tourism Data Management Systems
  • The difference between data management and data processing in a digital economy

    Data is critical for businesses, and understanding the differences between data management and data processing can be confusing. In this article, we will take a closer look at these differences in the digital economy to better understand their purposes and applications.

    The difference between data management and data processing in a digital economy