承接 rs/link-checker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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:

  1. IAM Role (Recommended for production environments like EC2 or ECS)
  2. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 rs/link-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-21