Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

A Laravel webshop

Earlier today Spatie, the company where I work, launched a webshop polkadots.be.

When the project started one of the first choices that we had to make was if we were going to use an existing solution or build our own custom solution. For this project we took an extensive look at some existing solutions.  Allthough the existing webshop systems are very powerful, we wanted to use something less bloated. At Spatie we’re big fans of simple, clean  and elegant solutions.To make a long story short we made the decision to build a shop ourselves.

Polkadots.be aims to be a very speedy application, that’s simple to use. Customers can buy products without having to make a user profile. Shop owners are presented a very clean interface to administer their shop.

On the clientside Rogier and Willem made a beautiful design for the shop. The various productlists you see on the site are rendered with Angular. Because all filtering is done by the browser you’ll never see “loading”-indicator on those pages. Your filter settings are stored in the local storage of your browser.

The serverside of the shop is built with Laravel 4.2 and leverages techniques such as repositories, domain events, presenters, factories, … Using these design patterns makes the code more readable and self-documenting. Ultimately it leads to a flexible codebase that can be easily adapted to future business requirements.

Of course we didn’t build everything from the ground up, many freely available packages were used. I’ll highlight some of them:

  • baum/baum: an implementation of the nested set pattern. It’s being used to store the hierarchical relation between productcategories.
  • davejamesmiller/laravel-breadcrumbs: offers a clean way to generate breadcrumbs.
  • gloudemans/shoppingcart: the basis for the cart. We built some methods on top of it so it can also store order options (such as “delivery method”) .
  • dyaa/pushover: used to send push notifications to the mobile device of the shop administrator. In case of polkadots the shop admin gets immediately notified of new orders or when a stock shortage is imminent.
  • vespakoen/menu: generates all menu’s you see on the site.
  • indatus/dispatcher: allows for the scheduling of artisan commands with the command itself so you don’t have to modify a crontab.
  • laracasts/commander: enables us to use domain events.
  • imagine/imagine: used to convert the product images to the right size.
  • michelf/php-markdown: converts the markdown that stored in the external product system of our client to html on de product pages.
  • league/flysystem: offers filesystem abstraction. Is used to retrieve images from the ftp-server of our client.
  • cviebrock/eloquent-sluggable: generates slugs for eloquent models.
  • itsgoingd/clockwork: used extensively to track down and solve n+1 issues.
  • spatie/payment: allows for payments to made. Take a look at the code of the offical Europabank plugin to understand why we made a payment solution ourselves. I’d rather [insert something very unpleasant here]  than using the official code.

Let’s take a look at the used infrastructure. The application is hosted on a Forge-provisioned Digital Ocean server. To cache some expensive queries we use Memcached. Mandrill is used to deliver all mails. All push notifications are being sent by Pushover.net. All communication with external systems is being done in Beanstalkd queues. We monitor the server with New Relic.  The site uses the SPDY protocol instead of regular http.

I believe our team did terrific job. Take a look at the shop and judge for yourself. If you have any remarks or questions let me know.

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band.
  • emini

    Thanks for sharing! Awesome Work!

  • Oğuz Çiçek

    inspiring , thank you !

  • michalgallovic

    Great job!

  • Amedora Ahmed


  • Adform Donatas Stirbys

    Guys, you could open source this. It would be a gift to the world.

  • billyct

    amazing! &great job!&thank you!&awesome work!

  • FightTheFuture

    This sounds like a great project! Well done

  • You are amazing… Thanks for sharing your knowledge, will really help a lot of beginners and intermediates like me build stuffs smarted and more effectively…

  • Daniel Villarreal

    You’ve already gave us a lot of information on how your company have created their own product, we need to build a similar product, Polkadots…. its AMAZING!!
    and beautiful

  • Roy

    How long did it take you from start to finish?

  • Binalf Kassa

    Great Job! May I ask what package you used for localisation?

  • Pingback: Integrating Algolia in a Laravel application | murze.be()

  • Pingback: This blog is one year old - murze.be()