adriengras/php-clamav
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
clamdfor 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
clamddaemon. (e.g.PING,VERSION,SCAN,CONTSCAN,INSTREAM,RELOAD,SHUTDOWN)
Requirements
- A ClamAV
clamddaemon running with either TCP or Unix socket enabled. - PHP
8.0or higher with thesocketsextension enabled.
You can easily run a ClamAV
clamddaemon using the official Docker image. More information can be found here.
⚠️ This repository contains a
docker-compose.ymlfile that you can use to run a ClamAVclamddaemon 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 :
- The appwrite/php-clamav package.
- @yani issue on the appwrite/php-clamav repository.
adriengras/php-clamav 适用场景与选型建议
adriengras/php-clamav 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.68k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「scan」 「virus」 「clamav」 「antivirus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adriengras/php-clamav 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adriengras/php-clamav 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adriengras/php-clamav 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
VirusTotal Public API v2.0 PHP Wrapper
AMWSCAN (Antimalware Scanner) is a php antimalware/antivirus scanner console script written in php for scan your project. This can work on php projects and a lot of others platform.
This repository provides a virus scan validator constraint for Symfony-based projects.
A Tissue adapter that implements the ClamAV virus-scanner
A PHP library that scans your files for viruses using the adapter of your choice
A Symfony bundle that let's you scan your files for viruses using the Tissue library
统计信息
- 总下载量: 10.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-07