定制 xenolope/quahog 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

xenolope/quahog

最新稳定版本:v3.0.0

Composer 安装命令:

composer require xenolope/quahog

包简介

A PHP client library for ClamAV clamd daemon

README 文档

README

Build Status

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

统计信息

  • 总下载量: 6.84M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 87
  • 点击次数: 2
  • 依赖项目数: 19
  • 推荐数: 2

GitHub 信息

  • Stars: 83
  • Watchers: 8
  • Forks: 24
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固