PHPackages                             sunspikes/clamav-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. sunspikes/clamav-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

sunspikes/clamav-validator
==========================

Custom Laravel 5 anti-virus validator for file uploads.

v3.1.0(1mo ago)3651.8M—4.2%74[10 issues](https://github.com/sunspikes/clamav-validator/issues)[2 PRs](https://github.com/sunspikes/clamav-validator/pulls)2MITPHPPHP ^7.3|^8.0

Since Oct 20Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/sunspikes/clamav-validator)[ Packagist](https://packagist.org/packages/sunspikes/clamav-validator)[ Docs](https://github.com/sunspikes/clamav-validator)[ RSS](/packages/sunspikes-clamav-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (36)Used By (2)

ClamAV Virus Validator For Laravel
==================================

[](#clamav-virus-validator-for-laravel)

[![Code Coverage](https://camo.githubusercontent.com/63800be65db7e77d632913fa4e9b992d7d5d49a81f78c40a022c418ff39c13f4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73756e7370696b65732f636c616d61762d76616c696461746f722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sunspikes/clamav-validator/?branch=master)[![Code Quality](https://camo.githubusercontent.com/96f13ce2d326108f15d97a85cc48a1b7a5e1e334c3b46749b80105d8a0e0ed61/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73756e7370696b65732f636c616d61762d76616c696461746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sunspikes/clamav-validator)[![Latest Stable Version](https://camo.githubusercontent.com/e4ccdd0fad31cd4474af573d7ff80e85e68164d7ff01173f60fa8635e8e545be/68747470733a2f2f706f7365722e707567782e6f72672f73756e7370696b65732f636c616d61762d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/sunspikes/clamav-validator)[![License](https://camo.githubusercontent.com/0471e59a93176a0407580965a1577cfb37c313a975376034556b105e39a524d5/68747470733a2f2f706f7365722e707567782e6f72672f73756e7370696b65732f636c616d61762d76616c696461746f722f6c6963656e7365)](https://packagist.org/packages/sunspikes/clamav-validator)

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

- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Author](#author)

Requirements
------------

[](#requirements)

- PHP &gt;= 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](http://www.clamav.net/documents/installing-clamav).

For example on an Ubuntu machine, you can do:

```
# 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
------------

[](#installation)

#### 1. Install the package through [Composer](http://getcomposer.org).

[](#1-install-the-package-through-composer)

```
composer require sunspikes/clamav-validator
```

#### 2. Publish assets from the vendor package

[](#2-publish-assets-from-the-vendor-package)

##### Config file

[](#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

[](#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
-------------

[](#configuration)

The package can be configured using environment variables:

Environment VariableDefaultDescription`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
-----

[](#usage)

Use it like any `Validator` rule:

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

Or in a Form Request:

```
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
------

[](#author)

Krishnaprasad MG \[@sunspikes\] and other [awesome contributors](https://github.com/sunspikes/clamav-validator/graphs/contributors)

###  Health Score

70

—

ExcellentBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity62

Solid adoption and visibility

Community32

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 76.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~119 days

Recently: every ~152 days

Total

33

Last Release

54d ago

Major Versions

v1.7.4 → v2.0.02019-09-09

v2.9.1 → v3.0.02024-10-01

PHP version history (3 changes)v1.0PHP &gt;=5.4.0

v1.7PHP &gt;=5.5.0

v2.6.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/75611?v=4)[Krishnaprasad MG](/maintainers/sunspikes)[@sunspikes](https://github.com/sunspikes)

---

Top Contributors

[![sunspikes](https://avatars.githubusercontent.com/u/75611?v=4)](https://github.com/sunspikes "sunspikes (63 commits)")[![hordijk](https://avatars.githubusercontent.com/u/4454086?v=4)](https://github.com/hordijk "hordijk (2 commits)")[![bdelamatre](https://avatars.githubusercontent.com/u/3412927?v=4)](https://github.com/bdelamatre "bdelamatre (1 commits)")[![bnoordsij](https://avatars.githubusercontent.com/u/8420034?v=4)](https://github.com/bnoordsij "bnoordsij (1 commits)")[![chrisLeeTW](https://avatars.githubusercontent.com/u/1946961?v=4)](https://github.com/chrisLeeTW "chrisLeeTW (1 commits)")[![damyon](https://avatars.githubusercontent.com/u/758959?v=4)](https://github.com/damyon "damyon (1 commits)")[![GuusLeeuw-IGN](https://avatars.githubusercontent.com/u/60770713?v=4)](https://github.com/GuusLeeuw-IGN "GuusLeeuw-IGN (1 commits)")[![imgrant](https://avatars.githubusercontent.com/u/5815412?v=4)](https://github.com/imgrant "imgrant (1 commits)")[![kendalltristan](https://avatars.githubusercontent.com/u/624655?v=4)](https://github.com/kendalltristan "kendalltristan (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![Levivb](https://avatars.githubusercontent.com/u/2494320?v=4)](https://github.com/Levivb "Levivb (1 commits)")[![marksalmon](https://avatars.githubusercontent.com/u/7000886?v=4)](https://github.com/marksalmon "marksalmon (1 commits)")[![sbine](https://avatars.githubusercontent.com/u/1902973?v=4)](https://github.com/sbine "sbine (1 commits)")[![thiagobbt](https://avatars.githubusercontent.com/u/2956060?v=4)](https://github.com/thiagobbt "thiagobbt (1 commits)")[![tudorrrrrr](https://avatars.githubusercontent.com/u/60345215?v=4)](https://github.com/tudorrrrrr "tudorrrrrr (1 commits)")[![TullariS](https://avatars.githubusercontent.com/u/7660175?v=4)](https://github.com/TullariS "TullariS (1 commits)")[![aedart](https://avatars.githubusercontent.com/u/1523223?v=4)](https://github.com/aedart "aedart (1 commits)")[![vigneshgurusamy](https://avatars.githubusercontent.com/u/6076800?v=4)](https://github.com/vigneshgurusamy "vigneshgurusamy (1 commits)")[![ashleyshenton](https://avatars.githubusercontent.com/u/26444425?v=4)](https://github.com/ashleyshenton "ashleyshenton (1 commits)")

---

Tags

clamavlaravellaravel-packagephpvalidatorlaravelvalidatorvirusclamav

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sunspikes-clamav-validator/health.svg)

```
[![Health](https://phpackages.com/badges/sunspikes-clamav-validator/health.svg)](https://phpackages.com/packages/sunspikes-clamav-validator)
```

###  Alternatives

[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[laravel-validation-rules/phone

Validate that a phone number is in the correct format

69355.5k](/packages/laravel-validation-rules-phone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
