Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Scotch.io:
Implementing Smart Search with Laravel and Typeahead.js
Jul 14, 2016 @ 17:12:41

The Scotch.io blog has posted a tutorial combining Laravel and the Typeahead.js library to create a "smart search" in your application. Most of the tutorial centers around the Typeahead.js code though, so with a bit of tweaking it could sit on top of just about any framework out there.

In a big web application, like an online market or a social network, one of the most important parts of the app is the search functionality. Having a great search feature will help your users find the right content(users, products, articles) quickly and easily.

In this tutorial, we are going to learn, how to enhance your default search field in your site with real-time suggestions from the database. We will be using Laravel, jQuery and Typeahead (Bloodhound as the suggestion engine) to implement the smart search and Bootstrap for the styling. So, let's get started.

He starts off by introducing the Typeahead.js library and the Bloodhound suggestion engine. He shows the installation (either via Bower, standalone download or included from a CDN) and a simple template with a search form and other Javascript requirements included. The tutorial covers some of the options you can set, what kinds of datasets it can work with and templates to use for the results. Next up, he brings in a default Laravel project and a "search" endpoint that queries user data and returns a JSON dataset of the results. The two pieces are then finally tied together with a few updates to the Javascript already created.

tagged: smart search tutorial laravel typeaheadjs javascript bloodhound

Link: https://scotch.io/tutorials/implementing-smart-search-with-laravel-and-typeahead-js


Trending Topics: