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

Flutter App Development: Essential Things You Should Know

Divided by mobile operating systems, companies have to develop their apps twice and roll them…

7 hours ago

7 Tips To Build Responsive & Dynamic Drupal Website For Your Business

For optimal user experience, consumers want responsive websites that are easy to use, multi-device friendly,…

2 days ago

OpenCart vs Magento: What You Should Choose in 2021

Users all over the world are faced with the problem of choosing a platform for…

1 week ago

Top 20 Android Open Source Projects

Reading codes and contributing to open source has been proven to be one of the…

3 weeks ago

Top 5 tools to proofread and edit essays with the help of software

Poor grammar and incorrect spelling can significantly lower the value of any literary work. Going…

7 hours ago

The Best 5 Career Advice for Web Design Students

Are you thinking of a career in web design but not sure where to start? The…

4 weeks ago