Download the PHP package jan-drda/laravel-google-custom-search-engine without Composer
On this page you can find all versions of the php package jan-drda/laravel-google-custom-search-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jan-drda/laravel-google-custom-search-engine
More information about jan-drda/laravel-google-custom-search-engine
Files in jan-drda/laravel-google-custom-search-engine
Package laravel-google-custom-search-engine
Short Description Laravel package to get Google Custom Search results from Google Custom Search Engine API for both free and paid version.
License MIT
Homepage https://github.com/jdrda/laravel-google-custom-search-engine
Informations about the package laravel-google-custom-search-engine
Laravel Google Custom Search Engine
Laravel package to get Google Custom Search results from Google Custom Search Engine API for both free and paid version.
Brief history
As Swiftype closed free plans, I started to find some alternative without too much coding, but was unsucessfull. The best I found was Spatie's Google Search package for Google CSE paid version, so I made some research and develop package similar way, but independent to Google CSE version.
Coffee for developers
If you like this project, you can buy me a coffee to help me get fresh. :) https://ko-fi.com/A067ES5
Installation
1/ Install with Composer
2/ Add the service provider to config/app.php
3/ Add alias for Facade to config/app.php
4/ Publish the config file
Configuration
Creating your custom search engine
- If you create your engine at https://cse.google.com/cse/ you will find the ID after you click at Settings
- Just check the URL you have like https://cse.google.com/cse/setup/basic?cx=search_engine_id 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
- go to https://console.developers.google.com, than
- click on the menu on the right side of the GoogleAPI logo and click on 'Create project'
- enter the name of the new project - it is up to you, you can use 'Google CSE'
- wait until project is created - the indicator is color circle on the top right corner around the bell icon
- API list is shown - search for 'Google Custom Search API' and click on it
- click on 'Enable' icone on the right side of Custom Search API headline
- click on the 'Credentials' on the left menu under the 'Library' section
- click on the 'Create credentials' and choose 'API key'
- 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.php
Usage
Simple usage
Create an object and call the function getResults to get first 10 results
Do not forget to map namespace with, so sample controller will look like this (in min. way)
It is only example controller name, you can use whatever you want, this is notice mainly for novices in Laravel
You can also get information about the search like total records and search time
Advanced usage
You can use any parameter supported at Google. List of parameters is here: https://developers.google.com/custom-search/json-api/v1/reference/cse/list#parameters
E.g. you want to get next 10 results
You can also get the raw result from Google including other information Full list of response variables is available here: https://developers.google.com/custom-search/json-api/v1/reference/cse/list#response
For getting the number of results only use
If you have more engines / more api keys, you can override the config variables with following functions
Documentation
Essetial documentation will be at Github Wiki Now is under the development.
License
This package is open-sourced software licensed under the MIT license
About
I am independent senior software consultant living in the Czech republic in IT business from 1997.