rs/link-checker
Composer 安装命令:
composer require rs/link-checker
包简介
Visits links and checks they are still working. Also tries to return the title of html pages and pdfs.
关键字:
README 文档
README
A robust and flexible package for checking the status of URLs within your Laravel application. It concurrently checks a list of URLs, follows redirects, and intelligently extracts page titles from both HTML pages and PDF documents.
PDF title extraction is handled via a configurable AWS Lambda function, allowing for powerful, serverless processing of PDF metadata. The package is designed with a clean, extensible architecture, making it easy to add new title extraction strategies in the future.
Installation
You can install the package via composer:
composer require rs/link-checker
Configuration
First, publish the configuration file to your application's config directory:
php artisan vendor:publish --provider="RedSnapper\LinkChecker\LinkCheckerServiceProvider" --tag="link-checker-config"
This will create a config/link-checker.php file.
PDF Title Extraction (Optional)
To enable title extraction from PDF documents, you must configure your AWS credentials and specify the ARN of your deployed Lambda function in your .env file.
The package will automatically use the official AWS SDK for PHP, which looks for credentials in the following order:
- IAM Role (Recommended for production environments like EC2 or ECS)
- Environment variables
# .env # Your default AWS region AWS_REGION=eu-west-1 # Credentials (only needed if not using an IAM Role) AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key # The full ARN of your PDF Title Extractor Lambda function AWS_PDF_TITLE_LAMBDA_ARN=arn:aws:lambda:us-east-1:123456789012:function:PdfTitleExtractor
If AWS_PDF_TITLE_LAMBDA_ARN is not set, the package will gracefully skip PDF title extraction without causing errors.
Usage
Using the Facade
You can use the LinkChecker facade to check an array of URLs. The check method returns a Collection of LinkCheckResult objects.
use RedSnapper\LinkChecker\Facades\LinkChecker; $urls = [ '[https://www.google.com](https://www.google.com)', // Will extract HTML title '[https://example.com/document.pdf](https://example.com/document.pdf)', // Will extract PDF title (if configured) '[https://example.com/broken-link](https://example.com/broken-link)', // Will report a 404 error ]; $results = LinkChecker::check($urls); foreach ($results as $result) { echo "URL: " . $result->originalUrl . "\n"; echo "Status: " . $result->status . "\n"; // e.g., 'ok', 'client_error' echo "Status Code: " . $result->statusCode . "\n"; // e.g., 200, 404 echo "Title: " . $result->title . "\n"; // e.g., 'Google', 'My Awesome PDF Title' echo "Error: " . $result->errorMessage . "\n\n"; }
Using Dependency Injection
For developers who prefer dependency injection over facades, you can type-hint the LinkCheckerInterface in your class constructor or method. Laravel's service container will automatically resolve the correct implementation.
use RedSnapper\LinkChecker\Contracts\LinkCheckerInterface; class YourService { protected $linkChecker; public function __construct(LinkCheckerInterface $linkChecker) { $this->linkChecker = $linkChecker; } public function checkSomeLinks() { $urls = ['[https://example.com](https://example.com)']; $results = $this->linkChecker->check($urls); // ... do something with the results } }
Passing Custom Options
The check method accepts an optional second argument for custom options, such as headers and a referrer. These options will be used for both the initial URL check and will be passed to the PDF extractor Lambda for maximum authenticity.
use RedSnapper\LinkChecker\Facades\LinkChecker; $pageUrl = '[https://www.my-client.com/links-page](https://www.my-client.com/links-page)'; $pdfUrl = '[https://example.com/document.pdf](https://example.com/document.pdf)'; $results = LinkChecker::check( [$pdfUrl], [ 'referrer' => $pageUrl, 'headers' => ['X-Custom-Request-ID' => '12345-abcde'] ] ); // The Lambda function will be invoked with both the Referer and X-Custom-Request-ID headers.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email param@redsnapper.net instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.
rs/link-checker 适用场景与选型建议
rs/link-checker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rs」 「link-checker」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rs/link-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rs/link-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rs/link-checker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Check probability of link is spam
Broken link checker for Craft CMS 5
WordPress Link Checker is a command line tool that checks for broken links on a WordPress website.
Fast, safe broken link scanner with bulk find/replace and auto-fix rules for WordPress content.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-21