PHP code example of jeffersongoncalves / laravel-semrush
1. Go to this page and download the library: Download jeffersongoncalves/laravel-semrush 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/ */
jeffersongoncalves / laravel-semrush example snippets
// config/semrush.php
return [
'key' => env('SEMRUSH_API_KEY'),
'database' => env('SEMRUSH_DATABASE', 'us'),
'base_url' => env('SEMRUSH_BASE_URL', 'https://api.semrush.com'),
];
use JeffersonGoncalves\Semrush\Facades\Semrush;
Semrush::domainOverview('example.com');
Semrush::domainOrganic('example.com', database: 'br', limit: 50);
Semrush::domainCompetitors('example.com', limit: 20);
Semrush::keywordOverview('laravel', database: 'us');
Semrush::relatedKeywords('laravel', database: 'us', limit: 25);
Semrush::keywordDifficulty('laravel');
Semrush::backlinksOverview('example.com');
Semrush::backlinks('example.com', targetType: 'domain', limit: 100);
use JeffersonGoncalves\Semrush\Semrush;
$semrush = app(Semrush::class);
$semrush->domainOverview('example.com');
Semrush::keywordOverview('laravel');
// [
// ['Ph' => 'laravel', 'Nq' => '12100', 'Cp' => '1.35', 'Co' => '0.07', 'Nr' => '154000000'],
// ]
Semrush::get([
'type' => 'phrase_this',
'phrase' => 'laravel',
'database' => 'us',
'export_columns' => 'Ph,Nq,Cp',
]);
use Illuminate\Http\Client\RequestException;
use JeffersonGoncalves\Semrush\Exceptions\SemrushException;
try {
$rows = Semrush::keywordOverview('laravel');
} catch (SemrushException $e) {
// "ERROR 50 :: NOTHING FOUND", "ERROR 120 :: WRONG KEY", ...
} catch (RequestException $e) {
// $e->response->status(), $e->response->body(), ...
}
bash
php artisan vendor:publish --tag="semrush-config"
bash
composer analyse