cacko/yii2-clamav A PHP interface to clamd / clamscan.

yii2-clamav

  1. Installation
  2. Configuration
  3. Usage

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');

0 0
1 follower
19 downloads
Yii Version: Unknown
License: MIT
Category: Security
Tags: clamav, yii2
Developed by: cacko
Created on: Mar 15, 2021
Last updated: 3 years ago
Packagist Profile
Github Repository

Related Extensions