Real-Time Auctions with Laravel

Real Time Auctions

In a real time auction an item is auctioned to the audience with a start price. The audience posts bids topping the price each time, till no more bids are received. At which the the item is considered to be sold to the last bidder (with the highest price).

Flow of Real-Time Auction

A collection of Internet users login to the site, see the current price, and post a bid with a higher price. Once a bid is received at the server, the current price is broadcast to all users, and should appear on the web page.

When no more bids are received after some time, an announcement of first call is broadcast on the web page. If no further bid is received after a shot while, it is followed by a similar second call, to be followed by a third call. Upon which the item is announced to be sold.

Architecture of Web Site for Real-Time Auctions

This flow entails an architecture in which:

  • Calls are made via some transport from the front end client (web page) to the server
  • The server broadcasts information to the front end client, thereby causing a dynamic update of the web page

While the flow from client to server is the standard HTTP request-response protocol, the server to client broadcast requires something different. with Node.js

Most often we would use with a Node.js server.

Real-Time Auctions with Node.js

In a previous article, Real-Time Auctions with Node.js, I have described how to implement the bidding and broadcast flow with Node.js and

That architecture was successfully used in production system of an antique house, A Production Real-Time Auctions System.

Dual Architecture

We liked this architecture, but its dual nature involving two servers:

  • Real-time Node.js of communication
  • Laravel PHP web application on Nginx web server

Required complicated programming and juggling interaction between the two servers. So I felt we should look for a better way.

Enter Laravel Echo.


Laravel is one of the most popular PHP frameworks. It supports PHP 7. Laravel as a convenient local development environment using Vagrant.

Laravel 5.4 supports broadcasting events from the server-side to the front end using Laravel Echo. Laravel Echo is a small JavaScript library to be included in your layouts. Transport from the server side to the front end can carried through one of:

Real-Time Auctions with Laravel

Of the two flows of information in a real-time auction architecture, the calls from the front end to the server are natural to do in Ajax to some action of a Laravel controller.

The more complicated stuff is the broadcast from the server to the client. Here Laravel Echo is the natural thing to do. You do not need to implement the Node.js server, as there is a community driven Socket.IO server is currently maintained at the tlaverdure/laravel-echo-server GitHub repository.

So now we have our whole architecture in Laravel. This simplifies maintaining our database, as Laravl is our single source of truth.