elephant / status
此包最新版本(v0.4.0-alpha)没有提供许可证信息。
检查页面响应码。检查网站上的404错误。
v0.4.0-alpha
2020-10-04 15:03 UTC
Requires
- php: >=7.3
- ext-dom: *
- ext-mbstring: *
- ext-simplexml: *
- guzzlehttp/guzzle: 7.0
- twig/twig: 3.0.*
Requires (Dev)
- phpunit/phpunit: ^9.4
Suggests
- guzzlehttp/guzzle: Required for http requests
This package is auto-updated.
Last update: 2024-09-16 22:32:04 UTC
README
ElephantStatus - 用于检查网站页面(链接)响应代码的库。用PHP编写。它可以检查网站页面上的404错误或301重定向。
安装
使用 Composer 安装
$ composer require elephant/status
需要先确保在 composer.json 中设置了 "minimum-stability": "alpha" 或 "minimum-stability": "dev"
文档
基本使用
use Elephant\Elephant; use Elephant\Parser\SitemapParser; use Elephant\Reports\DisplayReport; $report = new DisplayReport(); $sitemap = new SitemapParser('sitemap.xml', false, true, 20); $elephant = new Elephant([ 'base_uri' => 'https://foo.com', 'parser' => $sitemap, 'report' => $report ]); $elephant->generateReport();
- $sitemapPath = sitemap.xml - 网站地图路径。默认为 sitemap.xml,也可以指定其他路径。默认为 sitemap.xml,非必须。
- $checkLinks = false - 是否需要检查网站地图中的链接是否符合 base_uri。如果为 true,则不会检查以下类型的链接: http://www.foo.ru 或 http://www.site.com。默认为 false,非必须。
- $sitemapFollow = true - 是否需要跳过网站地图中的其他链接,如果它们在主文件 $sitemapPath 中找到。默认为 false,非必须。
- $maxLinks = 2 - 需要检查的链接数量。如果不限制数量,则设置为 0,将检查所有链接。默认为 0,非必须。
使用示例
使用示例可以在 samples 文件夹中找到