百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

clamav-validator

> 后端框架
开源

基于 ClamAV 防病毒扫描程序的 Laravel 病毒验证器

374 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

基于 ClamAV 防病毒扫描程序的 Laravel 病毒验证器

ClamAV Virus Validator For Laravel

A custom Laravel virus validator based on ClamAV anti-virus scanner for file uploads.

  • Requirements
  • Installation
  • Configuration
  • Usage
  • Author

Requirements

  • PHP >= 8.0
  • Laravel 9.x, 10.x, 11.x, 12.x, or 13.x
  • ClamAV anti-virus scanner running on the server

You can see the ClamAV installation instructions on the official ClamAV documentation.

For example on an Ubuntu machine, you can do:

bash
# Install clamav virus scanner
sudo apt-get update && sudo apt-get install -y clamav-daemon

# Update virus definitions
sudo freshclam

# Start the scanner service
sudo systemctl enable --now clamav-daemon clamav-freshclam

This package is not tested on Windows, but if you have ClamAV running (usually on port 3310) it should work. You will also need to have sockets extension installed and enabled (all executions without this module will fail with this error - "Use of undefined constant 'AF_INET'").

Installation

1. Install the package through Composer.

bash
composer require sunspikes/clamav-validator

2. Publish assets from the vendor package

Config file

The default configuration file does use ENV to override the defaults. If you want to change the configuration file anyway you run the following command to publish the package config file:

php artisan vendor:publish --provider="Sunspikes\ClamavValidator\ClamavValidatorServiceProvider" --tag=config

Once the command is finished you should have a config/clamav.php file that will be used as well.

Language files

If you want to customize the translation or add your own language you can run the following command to publish the language files to a folder you maintain:

php artisan vendor:publish --provider="Sunspikes\ClamavValidator\ClamavValidatorServiceProvider" --tag=lang

This will copy the language files to lang/vendor/clamav-validator.

Configuration

The package can be configured using environment variables:

Environment Variable Default Description
CLAMAV_PREFERRED_SOCKET unix_socket Socket type: unix_socket or tcp_socket
CLAMAV_UNIX_SOCKET /var/run/clamav/clamd.ctl Path to the ClamAV unix socket
CLAMAV_TCP_SOCKET tcp://127.0.0.1:3310 TCP socket connection string
CLAMAV_SOCKET_CONNECT_TIMEOUT null Connection timeout in seconds (null = no limit)
CLAMAV_SOCKET_READ_TIMEOUT 30 Read timeout in seconds
CLAMAV_CLIENT_EXCEPTIONS false Throw exceptions on scan failures instead of returning validation failure
CLAMAV_SKIP_VALIDATION false Skip virus scanning entirely (useful for local development)

Usage

Use it like any Validator rule:

php
$rules = [
    'file' => 'required|file|clamav',
];

Or in a Form Request:

php
class UploadRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'file' => 'required|file|clamav',
        ];
    }
}

ClamavValidator will automatically run multiple files one-by-one through ClamAV in case file represents multiple uploaded files.

Author

Krishnaprasad MG [@sunspikes] and other awesome contributors

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPclamavlaravellaravel-packagephp

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架