revolution / laravel-google-searchconsole
Google SearchConsole API for Laravel
3.2.0
2024-02-20 05:48 UTC
Requires
- php: ^8.1
- google/apiclient: ^2.12
- illuminate/container: ^10.0||^11.0
- illuminate/support: ^10.0||^11.0
- pulkitjalan/google-apiclient: ^6.0
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.0
README
https://developers.google.com/webmaster-tools/search-console-api-original/
Requirements
- PHP >= 8.1
- Laravel >= 10.0
Versioning
- Basic : semver
- Drop old PHP or Laravel version :
+0.1
. composer should handle it well. - Support only latest major version (
master
branch), but you can PR to old branches.
Installation
composer require revolution/laravel-google-searchconsole
This package depends on
- Socialite
- https://github.com/google/google-api-php-client
- https://github.com/pulkitjalan/google-apiclient
Google_Service_Webmasters
https://github.com/googleapis/google-api-php-client-services/tree/master/src/Google/Service/Webmasters
Get API Credentials
from https://developers.google.com/console
Enable Google Search Console API
.
publish config file
php artisan vendor:publish --provider="PulkitJalan\Google\GoogleServiceProvider" --tag="config"
config/google.php
'client_id' => env('GOOGLE_CLIENT_ID', ''), 'client_secret' => env('GOOGLE_CLIENT_SECRET', ''), 'redirect_uri' => env('GOOGLE_REDIRECT', ''), 'scopes' => [\Google\Service\Webmasters::WEBMASTERS], 'access_type' => 'offline', 'approval_prompt' => 'force', 'prompt' => 'consent', //"none", "consent", "select_account" default:none
config/service.php for Socialite
'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID', ''), 'client_secret' => env('GOOGLE_CLIENT_SECRET', ''), 'redirect' => env('GOOGLE_REDIRECT', ''), ],
Configure .env as needed
GOOGLE_APPLICATION_NAME=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT=
Demo
https://github.com/kawax/laravel-searchconsole-project
Usage
See demo project and docs.
Or another Google API Series.
Query class
Subclass of Google\Service\Webmasters\SearchAnalyticsQueryRequest.
Make command
Create at app/Search
php artisan make:search:query NewQuery
Query class must have init()
method.
namespace App\Search; use Revolution\Google\SearchConsole\Query\AbstractQuery; class NewQuery extends AbstractQuery { public function init() { // } }
LICENSE
MIT