cacko / yii2-clamav
A PHP interface to clamd / clamscan.
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- php: >=7.3
- ext-sockets: *
- yiisoft/yii2-bootstrap: 2.*
This package is auto-updated.
Last update: 2023-08-29 02:44:14 UTC
README
yii2-clamav is a Yii2 component to clamd / clamscan that allows you to scan files and directories using ClamAV. it's a fork of https://github.com/vanagnostos/php-clamav adapted for Yii2
Installation
composer require cacko/yii2-clamav
Configuration
via unix socker
<?php 'components' => [ ..... 'clamav' => [ 'class' => 'Cacko\ClamAv\Scanner', 'driver' => 'clamd_local', 'socket' => '/var/run/clamav/clamd.sock' ],
using executable
<?php 'components' => [ ..... 'clamav' => [ 'class' => 'Cacko\ClamAv\Scanner', 'driver' => 'clamscan', 'executable' => '/usr/local/bin/clamdscan' ],
using local tcp socket
<?php 'components' => [ ..... 'clamav' => [ 'class' => 'Cacko\ClamAv\Scanner', 'driver' => 'clamd_local', 'host' => '127.0.0.1', 'port' => 3310 ],
using remote tcp socket
<?php 'components' => [ ..... 'clamav' => [ 'class' => 'Cacko\ClamAv\Scanner', 'driver' => 'clamd_remote', 'host' => '192.168.0.10', 'port' => 3310 ],
dummy driver - does nothing
<?php 'components' => [ ..... 'clamav' => [ 'class' => 'Cacko\ClamAv\Scanner', 'driver' => 'dummy', ],
Usage
Scan file
<?php $result = Yii::$app->clamav->scan('my_file.txt');
Scan text
<?php $result = Yii::$app->clamav->scanBuffer(file_get_contents('my_file.txt'));
Scan file as object
<?php $result = Yii::$app->clamav->scanResource(new SplFileObject('my_file.txt'), 'rb');