sineflow/clamav
Composer 安装命令:
composer require sineflow/clamav
包简介
ClamAV PHP Client for Symfony
README 文档
README
This library is a PHP client for working with a ClamAV daemon. It also provides optional Symfony integration.
Requirements:
You need to have ClamAV installed and configured to accept socket and/or network connections: https://docs.clamav.net/manual/Installing.html
Installation
$ composer require sineflow/clamav
Usage as a standalone library
$scanner = new Scanner(new ScanStrategyClamdUnix($socket)); $scanner = new Scanner(new ScanStrategyClamdNetwork($host, $port));
Usage as a Symfony bundle
Enable the bundle
// config/bundles.php return [ // ... Sineflow\ClamAV\Bundle\SineflowClamAVBundle::class => ['all' => true], ];
Configuration:
sineflow_clam_av: strategy: clamd_unix socket: "/var/run/clamav/clamd.ctl"
or
sineflow_clam_av: strategy: clamd_network host: 127.0.0.1 port: 3310
Scanning files
use Sineflow\ClamAV\Scanner; use Sineflow\ClamAV\Exception\FileScanException; use Sineflow\ClamAV\Exception\SocketException; public function myAction(Scanner $scanner) { try { $scannedFile = $scanner->scan($file); if (!$scannedFile->isClean()) { echo $scannedFile->getVirusName(); } } catch (SocketException $e) { ... } catch (FileScanException $e) { ... } }
Scanning streams
When the file is not on the local filesystem or not accessible to the ClamAV daemon (e.g. files stored via Flysystem in S3, SFTP, etc.), you can use scanStream() to send the file contents directly to ClamAV via its INSTREAM protocol.
use Sineflow\ClamAV\Scanner; use Sineflow\ClamAV\Exception\FileScanException; use Sineflow\ClamAV\Exception\SocketException; // In a real application, the stream would typically come from // Flysystem's readStream(), an HTTP response, or similar source. public function myAction(Scanner $scanner) { $stream = fopen('/path/to/file', 'rb'); try { $scannedFile = $scanner->scanStream($stream, 'my-upload.pdf'); if (!$scannedFile->isClean()) { echo $scannedFile->getVirusName(); } } catch (SocketException $e) { ... } catch (FileScanException $e) { ... } finally { fclose($stream); } }
Running tests
docker compose run --rm phpunit
docker compose down
sineflow/clamav 适用场景与选型建议
sineflow/clamav 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 208.25k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2020 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「bundle」 「clamav」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sineflow/clamav 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sineflow/clamav 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sineflow/clamav 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
Provide a way to secure accesses to all routes of an symfony application.
Antivirus scanner for Laravel
This repository provides a virus scan validator constraint for Symfony-based projects.
DMS Meetup API Bundle, enables Meetup API clients in services
统计信息
- 总下载量: 208.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-29