PHP code example of elfeffe / laravel-google-indexing

1. Go to this page and download the library: Download elfeffe/laravel-google-indexing library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elfeffe / laravel-google-indexing example snippets


storage_path('google_auth_config.json')

return [
    'google' => [
        'auth_config' => storage_path('google_auth_config.json'),
        'scopes' => [
            'https://www.googleapis.com/auth/indexing',
        ],
    ],
];

use Elfeffe\LaravelGoogleIndexing\Facades\LaravelGoogleIndexingFacade as LaravelGoogleIndexing;

LaravelGoogleIndexing::update('https://example.com/page');
LaravelGoogleIndexing::delete('https://example.com/page');
LaravelGoogleIndexing::status('https://example.com/page');

use Elfeffe\LaravelGoogleIndexing\LaravelGoogleIndexing;

$googleIndexing = new LaravelGoogleIndexing();

$googleIndexing->update('https://example.com/page');

use Elfeffe\LaravelGoogleIndexing\LaravelGoogleIndexing;

$googleIndexing = LaravelGoogleIndexing::forAuthConfig(
    storage_path('my-google-service-account.json')
);

use Elfeffe\LaravelGoogleIndexing\Traits\GoogleIndexable;
use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    use GoogleIndexable;

    public function getGoogleIndexingUrl(): string
    {
        return route('articles.show', $this);
    }
}

use Elfeffe\LaravelGoogleIndexing\LaravelGoogleIndexing;

$service = new LaravelGoogleIndexing();
$service->updateModel($article);

use Elfeffe\LaravelGoogleIndexing\Helpers\IndexingHelper;

$helper = app(IndexingHelper::class);

$helper->indexUrl('https://example.com/page');
$helper->indexUrls([
    'https://example.com/page-1',
    'https://example.com/page-2',
]);
$helper->indexModel($article);

$helper->isQuotaExceeded();
$helper->getRemainingQuota();

Article::getTodayIndexingCount();
Article::getRemainingDailyQuota();
Article::query()->needsGoogleIndexing(30)->get();

Elfeffe\LaravelGoogleIndexing\Exceptions\GoogleQuotaExceededException
bash
php artisan vendor:publish --tag=laravel-google-indexing-config
bash
php artisan vendor:publish --tag=laravel-google-indexing-migrations