Programming Languages at Gousto — PHP

Tech at Gousto caters to an entire spectrum of business needs and requirements. Teams with diverse skill-sets work on our customer-facing digital product as well as internal operations, processes and tooling using a range of libraries, frameworks, and languages at their disposal.

This post, the first in a series on programming languages at Gousto, will focus on our use of PHP.


Some of our teams are responsible for our website and apps, powered by REST API-based microservices. Others use artificial intelligence techniques to optimise warehouse throughput, or offer recommendations to customers. Some simplify complex order processing workflows using event-driven serverless architecture. And some offer valuable insight into customer behaviour using data refined through ETL pipelines.

Regardless of the business requirements, teams regularly assess technology options available to them. Whether it is deciding to use open-source frameworks and programming languages, or building something ourselves, we enjoy a good debate about the correct technology choice.

However, we prioritise delivering value to customers and growing Gousto in a controlled and sustainable way, over using the newest or trendiest technology.

Programming Languages

The main programming languages used at Gousto are Javascript, PHP, and Python. We also use Swift and Java for our mobile apps, but the first three are the most widespread.

Languages and frameworks used at Gousto

Javascript is primarily used to power our front-end applications, using React and NodeJS. Our REST APIs are mostly powered by PHP using Lumen, a widely-used Laravel-based microframework designed specifically for APIs. Finally, Python powers the majority of our event-driven workflows, our entire machine learning, data science, and data analytics functions, as well as the underlying CI/CD pipeline and tooling.

PHP at Gousto: The past

The first Gousto website was built on the Magento e-commerce platform in 2012. Without a dedicated Tech team, this enabled the company to get to market quickly and start growing using minimal resources.

Since the Magento platform was powered by PHP, the first hires into the internal Tech team were PHP developers, who could maintain and enhance the website. However, as business requirements rapidly outgrew the Magento platform, the second iteration of the Gousto web platform was created in late 2013 — a custom monolithic PHP application built using Laravel, which was the team’s area of expertise. This enabled complex custom functionality to be developed to meet the business’ rapidly growing requirements.

Over the next two years, Gousto grew rapidly, leading to growth in web traffic, as well as growth in the internal Tech team. The monolithic application became a bottleneck in this growth, and the team began the journey of breaking it apart into smaller services powered by Lumen, to enable both the team as well as the platform to scale.

Although the Tech team had grown by this point in time to have a range of programming skill sets, a conscious decision was taken to continue using PHP as the primary language for microservices exposed by REST APIs, for a number of reasons.

  • REST APIs at Gousto provide basic interaction with the different domains of data on the Gousto platform. As such, they have no significant performance requirements that are not achievable through a well-designed cache architecture.
  • Continuing the use of PHP and Lumen meant minimal refactoring was required to extract functionality out into smaller services, allowing the teams to focus on adding value. In fact, our overall migration strategy hinges on extracting out to a microservice only when new functionality is required.
  • Our experienced PHP engineers built an ecosystem of libraries and packages to enable sharing of common functionality between microservices. For example, an authentication package centralises authentication and authorisation, which is required across all our microservices; or an experiments package enables A/B testing across microservices.

The present

PHP is currently the second most commonly used language at Gousto after Python, constituting approximately 20% of all committed code in repositories.

It is primarily used for powering some of the REST API-based microservices at Gousto using Lumen. The engineering teams have built up a set of packages and standards around Lumen that enable them to develop API-based functionality rapidly, following industry-standard practices for security, stability and quality, and avoid pitfalls for which PHP is infamously known.

Teams at Gousto pay close attention to the PSR standards proposed and adopted by the PHP-FIG working group. These and other standards are regularly discussed within the Backend Guild, and teams decide if they want to adopt them internally. The PSR-2 standard has been widely adopted by teams, and the use of code-linters and SonarQube ensures conformity across teams and APIs. The PSR-3 logging standard is followed in lumberjack, a logging package that is shared across APIs; similarly the PSR-7 standard is followed in requesto, a package used for inter-microservice communication.


One of the PHP packages developed at Gousto over the last 18 months is Chef* – a cornerstone that has streamlined development of REST API-based microservices at Gousto.

Request and response flow in a REST API microservice

The diagram above shows how a request flows through a REST API at Gousto, typical for implementations across the industry. Chef provides an engine that implements this strategy, and abstracts away the need for engineers to write tedious and repetitive code to implement and handle these flows.

Building upon open-source packages such as Pipeline and Fractal, Chef enables engineers at Gousto to bootstrap REST APIs within minutes and focus on important domain logic, whilst ensuring the API follows industry-standard best practices.


Requesto — a package used for API-based communication between microservices — is another great example of engineers at Gousto using SOLID principles to solve a fundamental problem. As the original PHP monolith has been broken down into smaller microservices, the chatter between microservices has grown rapidly. This has precipitated a need to standardise implementation and configuration of inter-microservice API calls, and reduce friction in the transition to microservices.

The implementation of Requesto uses the Eloquent ORM paradigm, which provides an intuitive and clean interface for working with databases in Laravel/Lumen.

The examples shown below demonstrate how, using Requesto, orders contained in an Orders service for a given user can be accessed from another service.

Defining a resource
Accessing data using the repository pattern in Chef

This approach has worked extremely well because of the primarily CRUD nature of the REST API-based microservices. From a service’s point-of-view, the interface remains the same for accessing data whether it resides in a database accessed using a driver, or in another service accessed using HTTP. This also reduces the friction in transitioning to microservices, as the use of interfaces and dependency injection of implementations allows code to be “lifted and shifted” from the monolith.


PHP 7 provides a number of new features that bring it in line with other modern programming languages, and enable developers to write better quality code. Exception handling has improved significantly through the introduction of Throwables and treating type and parse errors as exceptions instead of runtime errors.

Typing has significantly improved with strict typing, return type declaration and better type hinting, all of which enables developers to write more predictable and stable code.

Finally, the performance improvements in PHP 7 provide performance comparable to HHVM/Hack, which is used by Facebook. New features such as generators enable developers to write more resource-efficient algorithms.

Whilst Python has become the language of choice at Gousto as we transition to a more event-driven serverless architecture, teams have embraced PHP 7 at Gousto, and have already upgraded a number of existing applications to PHP 7 in production.

The future

PHP has matured since it was first used at Gousto, both within Gousto as well as across the industry. The development of interoperability standards, sharing of PHP best practices by companies like Facebook and Slack, and the advent of PHP 7 have all enabled PHP to leave its ugly past behind.

The ecosystem of PHP libraries and frameworks used within Gousto has enabled teams to rapidly develop and launch new features for our customers. Adopting and adhering to industry standards and programming best practices, enforcing these through automated tools, and sharing knowledge amongst our teams will continue ensure that we write secure, stable and performant code, no matter what programming language we choose.

Abu Shoaib Technical Architect

*Chef cooks up REST APIs for you, as well as delicious recipes using the ingredients in your Gousto box. No relation the well-known configuration management tool — we use Ansible at Gousto.

Gousto Engineering & Data Science

Gousto Engineering Blog