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.

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest


Get the best in web dev

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

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