xenolope/quahog
Composer 安装命令:
composer require xenolope/quahog
包简介
A PHP client library for ClamAV clamd daemon
README 文档
README
Quahog is a simple PHP library to interface with the clamd anti-virus daemon. It was written as all of the libraries out
there for interfacing with ClamAV from PHP use exec('clamscan'), which isn't exactly an ideal solution, as
clamscan loads the entire database into memory each time it is run - this doesn't, so it scans a lot (lot!) faster.
Installation
It is recommended to install Quahog through composer.
{
"require": {
"xenolope/quahog": "3.*"
}
}
Usage
// Create a new socket instance $socket = (new \Socket\Raw\Factory())->createClient('unix:///var/run/clamav/clamd.ctl'); # Using a UNIX socket $socket = (new \Socket\Raw\Factory())->createClient('tcp://192.168.1.1:3310'); # Using a TCP socket // Create a new instance of the Client $quahog = new \Xenolope\Quahog\Client($socket); // Scan a file $result = $quahog->scanFile('/tmp/virusfile'); // Scan a file or directory recursively $result = $quahog->contScan('/tmp/virusdirectory'); // Scan a file or directory recursively using multiple threads $result = $quahog->multiscanFile('/tmp/virusdirectory'); // Scan a stream, and optionally pass the maximum chunk size in bytes $result = $quahog->scanStream(file_get_contents('/tmp/virusfile'), 1024); // Scan multiple files in a row $quahog->startSession(); $result = $quahog->scanFile('/tmp/virusfile'); $result2 = $quahog->scanFile('/tmp/virusfile2'); $quahog->endSession(); // Ping clamd $result = $quahog->ping(); // Get ClamAV version details $result = $quahog->version(); // View statistics about the ClamAV scan queue $result = $quahog->stats(); // Reload the virus database $quahog->reload(); // Shutdown clamd cleanly $quahog->shutdown();
Working with the result
// Result is an instance of \Xenolope\Quahog\Result. $result = $quahog->scanFile('/tmp/virusfile'); // A result id of a session that was used. $result->getId(); // The file name of the scanned file. $result->getFilename(); // The reason why a scan resulted in a failure. Returns null if the scan was successful. $result->getReason(); // A boolean value that is true, in case the scan was successful. $result->isOk(); // A boolean value that is true, in case the scan failed. This is the opposite of isOk(). $result->hasFailed(); // A boolean value that is true, if a virus was found. $result->isFound(); // A boolean value that is true, if an error happened. $result->isError();
Testing
To run the test suite you will need PHPUnit installed. Go to the project root and run:
$ phpunit
License
Quahog is released under the MIT License
xenolope/quahog 适用场景与选型建议
xenolope/quahog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.06M 次下载、GitHub Stars 达 83, 最近一次更新时间为 2016 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 xenolope/quahog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xenolope/quahog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.06M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 87
- 点击次数: 22
- 依赖项目数: 20
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-07