euclid1990 / php-google-suggest
PHP Google suggest keyword tool. Google suggest search result.
Installs: 100
Dependents: 0
Suggesters: 0
Security: 0
Stars: 18
Watchers: 3
Forks: 16
Open Issues: 0
Requires
- php: >=5.4
- illuminate/config: ~5.0
Requires (Dev)
- phpunit/phpunit: ~4.1
This package is not auto-updated.
Last update: 2024-11-21 01:06:28 UTC
README
PHP Google suggest keyword tool. Google suggest search result.
Installation
PHP 5.4 is required.
The PHP Google Suggest Service Provider can be installed via Composer by requiring the
euclid1990/php-google-suggest
package in your
project's composer.json
.
{ "require": { "euclid1990/php-google-suggest": "~1.0" }, "minimum-stability": "stable" }
or
Require this package with composer:
composer require euclid1990/php-google-suggest
Update your packages with composer update
or install with composer install
.
Setup
Commmon
Add boostrap autoload file:
require_once __DIR__ . '/../vendor/autoload.php'; use euclid1990\PhpGoogleSuggest\GoogleSuggest;
For Laravel
To use the Google Suggest Service, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this.
Find the providers
key in config/app.php
and register the Google Suggest Service Provider.
'providers' => [ // ... 'euclid1990\PhpGoogleSuggest\Providers\GoogleSuggestServiceProvider', ]
for Laravel 5.1+
'providers' => [ // ... euclid1990\PhpGoogleSuggest\Providers\GoogleSuggestServiceProvider::class, ]
Find the aliases
key in config/app.php
.
'aliases' => [ // ... 'GoogleSuggest' => 'euclid1990\PhpGoogleSuggest\Facades\GoogleSuggest', ]
for Laravel 5.1+
'aliases' => [ // ... 'GoogleSuggest' => euclid1990\PhpGoogleSuggest\Facades\GoogleSuggest::class, ]
Usage
1. Common PHP:
Please refer to demo/run.php or you can execute this command line:
# php demo/run.php
require_once __DIR__ . '/../vendor/autoload.php'; use euclid1990\PhpGoogleSuggest\GoogleSuggest; $configArr = require __DIR__.'/../config/google_suggest.php'; $config = ['google_suggest' => $configArr]; $googleSuggest = new GoogleSuggest(new Illuminate\Config\Repository($config)); $english = 'Google'; $result = $googleSuggest->search($english, $configArr['language']); echo "Search results for English keyword.\n"; print_r($result); $japanese = 'あいうえお'; $result = $googleSuggest->search($japanese, $configArr['language']); echo "Search results for Japanese keyword.\n"; print_r($result); $vietnamese = 'tìm'; $result = $googleSuggest->search($vietnamese, $configArr['language']); echo "Search results for Vietnamese keyword.\n"; print_r($result);
Result:
2. For Laravel
$keyword = 'suggest'; // Class method \GoogleSuggest::search($keyword); // Helper google_suggest($keyword);