volt / modern_php_scanner
从数组中扫描URL并返回不可访问的URL数组。这是Josh Lockhart的2015年书籍《Modern PHP》中的一个示例组件
0.1.1
2016-03-20 18:28 UTC
Requires
- php: >=5.4
- guzzlehttp/guzzle: >=5.3
Requires (Dev)
- phpunit/phpunit: 4.*
Suggests
- league/csv: CSV data manipulation made easy in PHP
This package is auto-updated.
Last update: 2024-08-29 03:58:08 UTC
README
这仅仅是一个教育测试项目。它是Josh Lockhart的O'Reilly(2015年)出版的《Modern PHP》书中略微修改过的示例。
有关原始代码,请参阅相关的GitHub页面a related GitHub page。您还可以查看修改过的代码[分支版本](https://github.com/frankperez87/scanner/blob/master/src/Url/Scanner.php)。
该组件使用PSR-4自动加载并利用Oreilly\ModernPhp\
命名空间。
对于类识别,使用\Oreilly\ModernPhp\Url\Scanner
类名称。
安装
通过Composer
$ composer require volt/modern_php_scanner
使用方法
// an array of test links $a_urls = array( 'http://www.pravda.com.ua', 'http://www.xpravda.ua', 'https://php.ac.cn/manual/ru/wrappers.php.php', 'http://uberhumor.com/', 'https://github.com/frankperez87/scanner/blob/master/src/Url/Scanner.php', 'https://www.google.com.ua/maps/' ); $o_scanner = new \Oreilly\ModernPhp\Url\Scanner($a_urls); // instantiate the component class $a_invalid_urls_arrays = $o_scanner->getInvalidUrls(); // get an array with resutls of scan // print_r($a_invalid_urls_arrays); // == the end == // the rest of the code below is compiling html markup for output in $c_html_url_result // from array of arrays ($a_invalid_urls_arrays) $c_html_url_result = null; if (empty($a_invalid_urls_arrays)) { $c_html_url_result = "<h2>All provided URLs are valid</h2>"; } else { $c_html_lis = null; foreach((array)$a_invalid_urls_arrays as $a_url_data){ $c_url = array_key_exists('url', $a_url_data)? $a_url_data['url'] : 'N/A'; $n_status_code = array_key_exists('status_code', $a_url_data)? $a_url_data['status_code'] : 'N/A'; $c_html_url = htmlspecialchars($c_url, ENT_QUOTES); $c_html_lis .= "<li><span>{$c_html_url}</span> Status message: <code>{$n_status_code}</code></li>"; }//endforeach $c_html_url_result = "<h2>The following URLs are invalid:</h2>" . "<ul>" . $c_html_lis . "</ul>"; }//endif echo $c_html_url_result;
变更日志
无需查看CHANGELOG,因为没有计划添加其他更改信息。
测试
$ composer test
贡献
请参阅CONTRIBUTING和CONDUCT以获取详细信息。
安全
请记住,这仅仅是一个测试项目。如果您发现任何安全相关的问题,请忽略它们。您还可以使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅许可证文件。