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!

Using Elasticsearch in Laravel

Elasticsearch is a lightning quick open source search server. It’s java-based (but don’t let that scare you) and can index and search documents. If you want to know more about it, watch this excellent talk by Ben Corlett.

For a recent Laravel project I had to index some data. In the process I’ve created a small package to talk to Elasticsearch in a clean way.

Basically it provides:

  • an interface that makes your objects searchable
  • some easy to use functions to put those objects into the search index
  • a function to retrieve search results from the index

You’ll find more detailed instructions and some examples on Github.


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. He loves waffles and butterflies.