Tutorials , code & Inspiration

How to add Google Custom Search Engine with laravel

In this article i will discuss about integrating google custom seach engine with laravel for this i will be using laravel package called googlesearch . This package can fetch results from a Google Custom Search Engine. It returns an array with searchresults. You’ll need to know how to set up a Google Custom Search Engine.


Laravel compatibility

Laravel googlesearch
4.2.x 1.x
5.x 2.x


This package can be installed through Composer.

composer require spatie/googlesearch

When using Laravel there is a service provider that you can make use of.

// Laravel 5: config/app.php

'providers' => [

GoogleSearch also comes with a facade, which provides an easy way to call the the class.

// Laravel 5: config/app.php

'aliases' => [
    'GoogleSearch' => 'SpatieGoogleSearchFacadesGoogleSearch',

You can publish the config file of the package using artisan

php artisan vendor:publish --provider="SpatieGoogleSearchGoogleSearchServiceProvider"

This command creates a file within your config directory in which you can specify the id of the Custom Search Engine you want to use.

prevChapter 1 of 2


Get the best in web dev

Join dunebook.com and recieve best in web dev , once a week FREE

An email has been Sent to your Inbox ! Please Confirm your Subscription :)

Pin It on Pinterest