sinflow / clamav
ClamAV PHP 客户端用于 Symfony
v1.1.2
2024-04-06 10:59 UTC
Requires
- php: ^7.3 || ^8.0
- ext-sockets: *
- symfony/config: ~4.0 || ~5.0 || ~6.0 || ~7.0
- symfony/dependency-injection: ~4.0 || ~5.0 || ~6.0 || ~7.0
- symfony/http-kernel: ~4.0 || ~5.0 || ~6.0 || ~7.0
- symfony/yaml: ~4.0 || ~5.0 || ~6.0 || ~7.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.5
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-09-06 11:59:04 UTC
README
此库是一个用于与 ClamAV 守护进程交互的 PHP 客户端。它还提供可选的 Symfony 集成。
要求
您需要安装并配置 ClamAV 以接受套接字和/或网络连接: https://docs.clamav.net/manual/Installing.html
安装
$ composer require sineflow/clamav
作为独立库的使用
$scanner = new Scanner(new ScanStrategyClamdUnix($socket));
$scanner = new Scanner(new ScanStrategyClamdNetwork($host, $port));
作为 Symfony 扩展的使用
启用扩展
// config/bundles.php return [ // ... Sineflow\ClamAV\Bundle\SineflowClamAVBundle::class => ['all' => true], ];
配置
sineflow_clam_av:
strategy: clamd_unix
socket: "/var/run/clamav/clamd.ctl"
或
sineflow_clam_av:
strategy: clamd_network
host: 127.0.0.1
port: 3310
扫描文件
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) {
...
}
}