A Laravel package to scan and report dead or broken links in your Laravel application. It crawls your website and identifies any broken links (4xx/5xx status codes).
- Asynchronous crawling with configurable concurrency
- Configurable crawl depth
- Export results to Excel
- Web interface to view and manage broken links
- Detailed progress reporting
- Database storage of broken links
- Support for Laravel 8.x, 9.x, 10.x, and 11.x
You can install the package via composer:
composer require moinul/laravel-broken-link-scanner
- Publish the config file:
php artisan vendor:publish --provider="Moinul\LinkScanner\LinkScannerServiceProvider" --tag="config"
- Publish and run the migrations:
php artisan vendor:publish --provider="Moinul\LinkScanner\LinkScannerServiceProvider" --tag="migrations"
php artisan migrate
- (Optional) Publish the views if you want to customize them:
php artisan vendor:publish --provider="Moinul\LinkScanner\LinkScannerServiceProvider" --tag="views"
Scan your site for broken links:
# Scan using config start_url
php artisan broken-links:scan
# Scan specific URL
php artisan broken-links:scan https://example.com
# Scan with custom depth
php artisan broken-links:scan --depth=3
# Clear old results before scanning
php artisan broken-links:scan --clear-old
# Show detailed progress
php artisan broken-links:scan -v
# Show very detailed progress
php artisan broken-links:scan -vv
# Show debug level information
php artisan broken-links:scan -vvv
The package provides a web interface at /broken-links
to:
- View all broken links
- See status codes and reasons
- Export results to Excel
- Track when links were last checked
You can configure the package by editing the config/broken-links.php
file:
return [
// The URL to start scanning from
'start_url' => env('APP_URL', 'http://localhost'),
// How many links deep should the crawler go? Set to -1 for unlimited
'max_depth' => env('BROKEN_LINKS_MAX_DEPTH', 5),
// How many URLs to check simultaneously
'concurrency' => env('BROKEN_LINKS_CONCURRENCY', 10),
// How long to wait for each request (in seconds)
'timeout' => env('BROKEN_LINKS_TIMEOUT', 10),
// The user agent string to use when making requests
'user_agent' => env('BROKEN_LINKS_USER_AGENT', 'Laravel Broken Link Scanner'),
// The database table to store broken links in
'storage_table' => 'broken_links',
];
You can also use the facade to scan programmatically:
use Moinul\LinkScanner\Facades\LinkScanner;
// Scan using config start_url
LinkScanner::scan();
// Scan specific URL
LinkScanner::scan('https://example.com');
The package dispatches the following events:
BrokenLinkFound
: When a broken link is discoveredScanCompleted
: When the scan is complete
composer test
Please see CHANGELOG.md for more information on what has changed recently.
Please see CONTRIBUTING.md for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.