PHP code example of peterujah / broken-links-scanner
1. Go to this page and download the library: Download peterujah/broken-links-scanner 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/ */
peterujah / broken-links-scanner example snippets
use \Peterujah\BrokenLinks\Scanner;
// Define the starting URL for the scan
$url = 'https://luminova.ng/';
$host = 'luminova.ng';
$maxScan = 10; // Set to 0 to scan all URLs.
// Initialize the BrokenLinks class
$scanner = new Scanner($url, $host, $maxScan);
// Optionally set the path to save scanned URLs
$scanner->setPath($path);
if ($scanner->start() && $scanner->isCompleted()) {
// Get results from the scan
$brokenLinks = $scanner->getBrokenLinks();
$visitedUrls = $scanner->getVisitedUrls();
$errors = $scanner->getErrors();
$allUrls = $scanner->getUrls();
// Output the scanned data
echo "Broken Links:\n";
print_r($brokenLinks);
echo "\nVisited URLs:\n";
print_r($visitedUrls);
echo "\nErrors Encountered:\n";
print_r($errors);
echo "\nAll Extracted URLs:\n";
print_r($allUrls);
} else {
echo "Failed to complete the scan.\n";
}