Categories: LaravelReviews

Add Google Custom Search Engine in laravel

In this article we’ll be reviewing  Laravel Google Custom Search Engine package it allows you to easily add   Google Custom Search within you laravel app .  Well, there are not many possibilities if you want to have your own search engine on your site without too much programming. There were service called Swiftpe, where you had free plan – you just enter the URL of your site and you got HTML code to insert in you page – and you had your own fulltext search engine. Now there are only very expensive plans.

Nowadays, there is no simple solution, you cannot just import url or urls, but it is needed to convert them to documents, insert in some service like Algolia, learn the API and search and update by yourself, which is not very fast. You can use Google Custom Search engine the same way as Swiftype, but there are too much ads, which does not look very professional.

you can create Custom Search Engine for Laravel-project and use it in very simple way  like

$fulltext = new LaravelGoogleCustomSearchEngine(); // initialize
$results = $fulltext->getResults('some phrase'); // get first 10 results for query 'some phrase'
Of course it is necessary to create Custom Search Engine and API key, which is once operation and it is described in detail:


Creating your custom search engine

  1. If you create your engine at you will find the ID after you click at Settings
  2. Just check the URL you have like and the string after cx= is your search engine ID

!! Attention !! If you change style of your Custom search engine, the ID can be changed

Get your API key

  1. go to, than
  2. click on the menu on the right side of the GoogleAPI logo and click on ‘Create project’
  3. enter the name of the new project – it is up to you, you can use ‘Google CSE’
  4. wait until project is created – the indicator is color circle on the top right corner around the bell icon
  5. API list is shown – search for ‘Google Custom Search API’ and click on it
  6. click on ‘Enable’ icone on the right side of Custom Search API headline
  7. click on the ‘Credentials’ on the left menu under the ‘Library’ section
  8. click on the ‘Create credentials’ and choose ‘API key’
  9. your API key is shown, so copy and paste it here

Save the configuration values

Save search engine ID and api ID in your config/laravelGoogleCustomSearchEngine

Author  will  update the package with cache as you can query free to Google API only 100 request / day, which is suitable for small and middle-sized projects, but not for bigger ones, so I will pack all query to cache, because the site is not changed in 24 hours, so it is not necessary to query the same phrases from Google API, but I need some time to do that.
Deven Rathore

Deven is an Entrepreneur, and Full-stack developer, Constantly learning and experiencing new things. He currently runs and

Published by
Deven Rathore

Recent Posts

Free Applications and Websites to Enhance Coding Skills

Obtaining any skill means that one will continuously upgrade it to become professional. It’s impossible…

3 weeks ago

How to Use Disk Drill Partition Recovery Software for Mac

With the keyboard shortcut "Command(⌘) + Option(⌥) + Delete(⌫)" you can completely remove a file…

3 weeks ago

21 React Project Ideas for Beginners

For some weeks now, you have been putting in a lot of effort in understanding…

4 weeks ago

Reasons for Creating a Custom Transportation Management Software

Transportation management software is used by organizations to administer, control, and manage the transportation aspect…

1 month ago

21 Angular project ideas for beginners

Angular project ideas have become so handy in bringing evolution and slight changes to many…

2 months ago

Tips for Optimal SaaS Platform Development

According to BetterCloud, approximately 80 percent of mobile applications will be running on mobile software…

2 months ago