adriengras/php-clamav 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

adriengras/php-clamav

最新稳定版本:1.0.0

Composer 安装命令:

composer require adriengras/php-clamav

包简介

A PHP/Composer package to use ClamAV to scan folders and files for viruses

README 文档

README

This is a PHP client for the ClamAV virus scanner.

Features

  • ????️ Uses clamd for scanning.
  • ???? Supports scanning of files and directories.
  • ???? Supports scanning of streams.
  • ???? Supports of TCP and Unix sockets.
  • ✨ Supports nearly all the methods provided by the clamd daemon. (e.g. PING, VERSION, SCAN, CONTSCAN, INSTREAM, RELOAD, SHUTDOWN)

Requirements

  • A ClamAV clamd daemon running with either TCP or Unix socket enabled.
  • PHP 8.0 or higher with the sockets extension enabled.

You can easily run a ClamAV clamd daemon using the official Docker image. More information can be found here.

⚠️ This repository contains a docker-compose.yml file that you can use to run a ClamAV clamd daemon for testing purposes; but it is not recommended to use it in production.

Installation

You can install the package via composer:

composer require adriengras/php-clamav

Usage

First, you'll need an instance of the client:

<?php use AdrienGras\PhpClamAV\ClamAV; # with a TCP socket $client = new ClamAV::fromDSN('tcp://localhost:3310'); # or with host and port $client = new ClamAV::fromParts('localhost', '3310'); # or with a Unix socket $client = new ClamAV::fromDSN('unix:///var/run/clamav/clamd.sock');

Then, you can use nearly all the methods provided by the clamd daemon:

<?php # Ping the daemon, returns true if the daemon is alive, false otherwise $isPingable = $client->ping(); # Get the ClamAV version $version = $client->version(); # Reload the database $client->reload(); # Scan a file, returns true if the file is clean, false otherwise $result = $client->scan('/path/to/file.txt'); # Scan a directory, returns true if all the files are clean, false otherwise $infectedFiles = $client->scan('/path/to/directory'); # Scan a stream, returns true if the stream is clean, false otherwise # You can either pass a resource or a string. If you pass a string, the method will create a temporary stream. $stream = fopen('/path/to/file.txt', 'r'); $result = $client->scanInStream($stream); # or $fileToStream = '/path/to/file.txt'; $result = $client->scanInStream($fileToStream); # Scan and continue if a virus is found. # The method will return an array of infected files, or an empty array if no virus is found. $result = $client->continueScan('/path/to/directory'); # Shutdown the daemon $client->shutdown();

Testing

You can run the tests using the following commands:

docker compose up -d # wait until the clamav container is up (use docker compose logs clamav to check) ./vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

Please see SECURITY for details.

License

This project is under MIT Licence. Please see License File for more information.

Credits

This project is heavily inspired by :

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固