承接 lemaur/php-url-checker 相关项目开发

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

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

lemaur/php-url-checker

最新稳定版本:1.1.2

Composer 安装命令:

composer require lemaur/php-url-checker

包简介

Check the url response status code and reason phrase.

README 文档

README

Latest Version on Packagist Total Downloads License GitHub Tests Action Status GitHub Code Style Action Status GitHub Sponsors Trees

This package for PHP provide a class to check the URL HTTP response without downloading the HTTP content in response.

This reduces the bandwidth and the response time.

Support Me

Hey folks,

Do you like this package? Do you find it useful and it fits well in your project?

I am glad to help you, and I would be so grateful if you considered supporting my work.

You can even choose 😃:

Installation

You can install the package via composer:

composer require lemaur/php-url-checker

Usage

The class Lemaur\UrlChecker\UrlChecker provides a static method check where accepts the URL to check as first parameter and the user agent string as a second parameter.

Here you can see how to use it 👇

use Lemaur\UrlChecker\UrlChecker;

$response = UrlChecker::check(
    url: 'https://google.com', 
    userAgent: 'MyApp/1.0 (UrlChecker)',
    connectTimeout: 5,
    timeout: 10,
);
// \Lemaur\UrlChecker\DataTransferObject\CheckData

$response->statusCode;
// (int) 200

$response->reasonPhrase;
// (string) 'OK'

$response->headers:
// (array) ['Date' => ['Sun, 24 Mar 2024 09:06:08 GMT']]

That class also provides another method to help you write unit tests.

It mocks the response to prevents any external network call. It accepts an array of GuzzleHttp\Psr7\Response.

UrlChecker::fake([
    new \GuzzleHttp\Psr7\Response(200),
]);

$response = UrlChecker::check('https://dummy-url.com');

$response->statusCode;
// (int) 200

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Security Vulnerability

Please review our security policy on how to report security vulnerabilities.

Credits

This package has been inspired by Chris White's blog post.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-23