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.