1. Go to this page and download the library: Download kalimeromk/seo-report 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/ */
kalimeromk / seo-report example snippets
use KalimeroMK\SeoReport\Config\SeoReportConfig;
use KalimeroMK\SeoReport\SeoAnalyzer;
// Create config (empty = use defaults)
$config = new SeoReportConfig([]);
// Create analyzer
$analyzer = new SeoAnalyzer($config);
// Analyze URL
$result = $analyzer->analyze('https://ogledalo.mk/');
// Get values
echo $result->getUrl(); // "https://ogledalo.mk/"
echo $result->getScore(); // 83.33
echo $result->getGeneratedAt(); // DateTimeImmutable
// Get all results
$results = $result->getResults();
echo $results['title']['value']; // "Ogledalo - Orthodox news portal..."
echo $results['load_time']['value']; // 0.94
echo $results['page_size']['value']; // 14886
// Check if specific check passed
if ($results['title']['passed']) {
echo "Title is OK";
}
// Get API response (JSON)
$json = $result->toJson();
$array = $result->toArray();
use KalimeroMK\SeoReport\SeoAnalyzerWithDocker;
use KalimeroMK\SeoReport\Config\SeoReportConfig;
$config = new SeoReportConfig([]);
// Create analyzer with Docker support
$analyzer = new SeoAnalyzerWithDocker($config);
// Analyze URL - automatically com');
echo "LCP: " . $cwv['performance']['metrics']['lcp'] . "ms";
// Take screenshot
$screenshot = $analyzer->takeScreenshot('https://example.com', 'mobile');
$base64Image = $screenshot['screenshot']['base64'];
// JavaScript analysis
$js = $analyzer->getJavaScriptAnalysis('https://example.com');
echo "Framework: " . $js['pageInfo']['framework']; // React, Vue, etc.
echo "Console errors: " . $js['console']['errors'];
use KalimeroMK\SeoReport\Config\SeoReportConfig;
$config = new SeoReportConfig([
'request_timeout' => 10, // HTTP timeout in seconds
'request_http_version' => '2', // HTTP version: '1.1' or '2'
'request_user_agent' => 'MyBot/1.0', // Custom user agent
'request_proxy' => "http://proxy1:8080\nhttp://proxy2:8080", // Proxy list
'sitemap_links' => 100, // Max URLs from sitemap (-1 = unlimited)
'report_limit_min_title' => 10, // Min title length
'report_limit_max_title' => 70, // Max title length
'report_limit_min_words' => 300, // Min words on page
'report_limit_max_links' => 200, // Max links on page
'report_limit_load_time' => 3, // Max load time (seconds)
'report_limit_page_size' => 500000, // Max page size (bytes)
'report_score_high' => 10, // Points for high importance checks
'report_score_medium' => 5, // Points for medium importance checks
'report_score_low' => 0, // Points for low importance checks
]);
$analyzer = new SeoAnalyzer($config);
$result = $analyzer->analyze('https://example.com');
// Analyze all URLs from sitemap
$results = $analyzer->analyzeSitemap('https://example.com/sitemap.xml');
// Limit to first 50 URLs
$results = $analyzer->analyzeSitemap('https://example.com/sitemap.xml', 50);
// $results is array of AnalysisResult
foreach ($results as $result) {
echo $result->getUrl() . ' - Score: ' . $result->getScore() . "\n";
}
use KalimeroMK\SeoReport\Config\SeoReportConfig;
use KalimeroMK\SeoReport\SeoAnalyzer;
use KalimeroMK\SeoReport\SeoAnalyzerException;
class SeoReportController extends Controller
{
public function analyze(Request $request)
{
try {
$config = new SeoReportConfig(config('seo-report'));
$analyzer = new SeoAnalyzer($config);
$result = $analyzer->analyze($request->input('url'));
return response()->json($result->toArray());
} catch (SeoAnalyzerException $e) {
return response()->json([
'error' => 'Could not analyze URL: ' . $e->getMessage()
], 400);
}
}
}
use KalimeroMK\SeoReport\Config\SeoReportConfig;
use KalimeroMK\SeoReport\SeoAnalyzer;
class SeoReportController extends \yii\web\Controller
{
public function actionAnalyze()
{
$url = \Yii::$app->request->get('url');
$config = new SeoReportConfig(\Yii::$app->params['seo-report'] ?? []);
$analyzer = new SeoAnalyzer($config);
$result = $analyzer->analyze($url);
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return $result->toArray();
}
}
$analyzer = new SeoAnalyzerWithDocker($config);
if ($analyzer->hasDockerSupport()) {
echo "Full analysis with Core Web Vitals";
} else {
echo "Basic analysis (no Docker available)";
}
use KalimeroMK\SeoReport\SeoAnalyzerWithDocker;
use KalimeroMK\SeoReport\Config\SeoReportConfig;
$config = new SeoReportConfig([]);
$analyzer = new SeoAnalyzerWithDocker($config);
$result = $analyzer->analyze('https://example.com');
// Results e']}\n";
}
if (isset($results['javascript_rendering'])) {
$js = $results['javascript_rendering']['value'];
echo "Framework: {$js['framework']}\n";
echo "Hydration: " . ($js['has_hydration'] ? 'Yes' : 'No') . "\n";
echo "Console Errors: {$js['console_errors']}\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.