radowoj / searcher
This package is abandoned and no longer maintained.
No replacement package was suggested.
Unified search API with drivers for Bing and Google
v0.4.0
2017-04-21 18:01 UTC
Requires
- php: ^7.0
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2025-04-14 04:14:23 UTC
README
Unified search API for Google, Bing and maybe others in the future. Utilizes Guzzle for http requests.
Goal
- To use Google / Bing / possibly other Web Search Api with the same interface, regardless of which one is being used under the hood.
Requirements
- PHP >= 7.0
- guzzlehttp/guzzle
Installation
composer require radowoj/searcher
Usage
use GuzzleHttp\Client as GuzzleClient; use Radowoj\Searcher\SearchProvider\Bing; use Radowoj\Searcher\SearchProvider\Google; use Radowoj\Searcher\Searcher; $client = new GuzzleClient(); // // If you want to use Google // $searchProvider = new Google( $client, 'your-google-api-key', 'your-custom-search-cx-value-set-in-google-account-panel' ); // // Or if you want to use Bing // $searchProvider = new Bing( $client, 'your-bing-api-key' ); // // Rest of the necessary code is the same regardless of search provider used // $searcher = new Searcher($searchProvider); $results = $searcher->query('"nyan cat"') ->limit(10) ->offset(0) ->find(); //Array access var_dump(($results[5])->toArray()); //Traversable foreach($results as $result){ var_dump($result->toArray()); } //Countable var_dump(count($results)); //...and total-result-countable ;) var_dump($results->totalCount());