Laravel with Packages | Laravel Scout Algolia Search Example

In this tutorial, I will give you step by step example of a laravel scout full-text search. I will show you how to create a full-text search using laravel scout algolia.

You can follow this example for scout full-text search in laravel 6, laravel 7, laravel 8, and laravel 9 projects.

Laravel provides us with several new features and introduces new packages. Laravel provides Scout Package for full-text search from your Model. If you require to add a full-text search function in your laravel application then you have to choose the scout package to do.

In this example I am going to explain it step by step, so you can simply understand and use it in your laravel project. In this tutorial, I give from scratch so let’s follow a simple few steps and implement a full-text search function in your laravel application.

Laravel with Packages | Laravel Scout Algolia Search Example

In this step, if you haven’t a laravel application setup then we have to get a fresh laravel application. So run the below command and get a clean fresh laravel application.

In this step we have to add two packages, there are listed below:



Ok, so first we will install the “laravel/scout” package by the following command:

Now we have to publish configure file by using the bellow command, After this command runs, you will find the new file scout.php in the config folder and we will set configure details on it, so let’s run the bellow command:

Now we need to set the configuration queue is true in your env file:


Ok, now we have to install the package for "algolia", so let's run the below command:

Ok, now we have to set the id and secret of algolia, so first you have to create a new account on So if you haven’t an account on the site then click here and create a new account:

Ok, after login we have to get the application id and secret so click here and open that web page: GET APP ID and SECRET. After opening you will see below the screen and copy your id and secret.

Ok, now open your .env file and paste the id and secret as below:


In this step, we have to create migration for items table using Laravel PHP artisan command, so first fire bellow command:

After this command, you will find one file in the following path database/migrations and you have to put the below code in your migration file to create an items table.

After creating the “items” table you should create an Item model for items, so first create a file in this path app/Item.php and put the below content in the item.php file:


In this step, we need to create routes for adding new items and listing them. so open your routes/web.php file and add the following route.


In this step, now we should create a new controller as ItemSearchController in this path app/Http/Controllers/ItemSearchController.php. this controller will manage all listing items and add new item requests and return responses, so put the below content in the controller file:


In the Last step, let’s create item-search.blade.php(resources/views/item-search.blade.php) for the layout and we will write the design code here and put the following code:


Ok, now we are ready to run this example so quick run by the following command:

Now open your browser and run the below link:

If you have already added a few records to your table then you can index that records by running the following command:

Maybe it can help you.....



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store