PHPackages                             mgriego/flysystem-clamav - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. mgriego/flysystem-clamav

ActiveLibrary[File &amp; Storage](/categories/file-storage)

mgriego/flysystem-clamav
========================

The Flysystem ClamAV scanner acts as a passthrough filesystem, scanning files that are retrieved from or stored to a backing Flysystem adapter (ie Local, FTP, S3, etc).

v1.0(8y ago)4724.3k1MITPHPPHP &gt;=5.6.0

Since Aug 13Pushed 8y ago3 watchersCompare

[ Source](https://github.com/mgriego/flysystem-clamav)[ Packagist](https://packagist.org/packages/mgriego/flysystem-clamav)[ RSS](/packages/mgriego-flysystem-clamav/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

ClamAV Scanner for Flysystem
============================

[](#clamav-scanner-for-flysystem)

[![Build Status](https://camo.githubusercontent.com/84afc050e8b56b971682393f77d40a9eeb31f76e330181d98a3dd88132e1ada0/68747470733a2f2f7472617669732d63692e6f72672f6d67726965676f2f666c7973797374656d2d636c616d61762e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mgriego/flysystem-clamav)

This package provides a filesystem adapter for [Flysystem](https://github.com/thephpleague/flysystem) that scans files being read from and written to an underlying filesystem using the popular [ClamAV](https://www.clamav.net/) antivirus engine. This adapter acts as a passthrough adapter, sitting in between your application and whichever concrete Flysystem adapter you use to store your files. Since this scanner is itself a Flysystem adapter, it can be implemented in an existing application simply by dropping it in as a replacement to your existing Flysystem adapter so that all filesytem calls go through the ClamAV adapter. Simply pass your existing adapter as the "backing" adapter to the ClamAV adapter when you instantiate it, and the rest should be completely transparent to your application.

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

[](#requirements)

- [ClamAV](https://www.clamav.net/) - In order to utilize this package, you will need access to a running instance of the ClamAV `clamd` daemon. This package utilizes `clamd` for its speed. Other similar file scanning packages utilize `clamscan`, which requires reading and parsing the large virus database each time it is called. The `clamd` daemon, on the other hand, only has to read and parse the database when it starts up and when the database is refreshed, making it a much faster option. If you are utilizing [Docker](https://www.docker.com), then it is simple to get `clamd` up and running by utilizing one of the existing images from the [Docker Hub](https://hub.docker.com), such as the [infiniteproject/clamav](https://hub.docker.com/r/infiniteproject/clamav/) image. Be sure that whichever image you use provides a running `clamd` daemon. Images that simply run `clamscan` will not work with this adapter.
- [Flysystem](https://github.com/thephpleague/flysystem) - This package is a Flysystem filesystem adapter, so it goes without saying that you must be using Flysystem in your project either directly or via existing integrations (ie [Laravel](https://laravel.com)). In order to utilize this adapter, you must also use a concrete adapter that stores and retrieves the files from a real filesystem. If will be up to you as the developer (unless using an existing integration that provides the functionality for you) to set up the "backing" adapter and pass that adapter to the ClamAV adapter.

Installation
------------

[](#installation)

Via composer:

```
composer require mgriego/flysystem-clamav

```

Usage
-----

[](#usage)

In order to utilize this adapter, you must first set up your "backing" adapter and an instance of [Quahog](https://github.com/jonjomckay/quahog) that points to your `clamd` server.

First, set up your backing adapter like you would normally. For instance, if you are storing files using the `Local` adapter:

```
use League\Flysystem\Adapter\Local;

$backingAdapter = new Local(__DIR__.'/path/to/root');

```

Next, you must set up an instance of the Quahog ClamAV integration library. Quahog is automatically installed by Composer when using this package, so there is no need to require it explicitly. More info on how to set up your Quahog instance can be found in the [Quahog README](https://github.com/jonjomckay/quahog). If your `clamd` service is running via TCP port 3310 on the local machine's loopback adapter, you can instantiate Quahog like this:

```
use Socket\Raw\Factory as SocketFactory;
use Xenolope\Quahog\Client as ClamAVScanner;

// Create a new socket instance
$socket = (new SocketFactory())->createClient('tcp://127.0.0.1:3310');

// Create a new instance of the Client
$quahog = new ClamAVScanner($socket);

```

Once you have your backing adapter and scanner set up, you can instantiate this adapter. This adapter's constructor takes two required and one optional arguments:

1. The Quahog instance
2. The backing adapter instance
3. A boolean telling the adapter whether to scan files that are being copied using the `copy` operation. This parameter is optional and defaults to `false`. If this is set to `true`, the adapter will first scan the source file before telling the backing adapter to perform the copy.

```
use League\Flysystem\Filesystem;
use mgriego\Flysystem\ClamAV\ClamAvScannerAdapter;

// In this case, copies will be scanned.
$adapter = new ClamAvScannerAdapter($quahog, $backingAdapter, true);
$filesystem = new Filesystem($adapter);

```

Files are scanned during the `read`/`readStream`, `write`/`writeStream`, and `update`/`updateStream` operations. If the adapter is configured as such, files will also be scanned during the `copy` operation. If ClamAV detects malware in the file, a `\mgriego\Flysystem\ClamAV\VirusFoundException` exception will be thrown. The `getReason` method will return the name of the malware that was detected in the file, and the `getPath` method will return the path of the file that was being acted upon. Or you can simply call the standard `getMessage`method available on all Exceptions, and a message will be returned that contains both the path and the name of the malware.

Related packages
----------------

[](#related-packages)

Coming soon!

Acknowledgements
----------------

[](#acknowledgements)

This package wouldn't be possible without these great projects:

- The [Quahog](https://github.com/jonjomckay/quahog) PHP library for integrating with ClamAV
- The [Flysystem](https://github.com/thephpleague/flysystem) filesystem abstraction library for PHP
- The [ClamAV](https://www.clamav.net/) antivirus engine

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3197d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d328813d12c99924615dfbdcfdbf6dc1141d524ed9120a0be8bd52d48339e7a?d=identicon)[mgriego](/maintainers/mgriego)

---

Top Contributors

[![mgriego](https://avatars.githubusercontent.com/u/186428?v=4)](https://github.com/mgriego "mgriego (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mgriego-flysystem-clamav/health.svg)

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

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[league/flysystem-local

Local filesystem adapter for Flysystem.

226231.8M39](/packages/league-flysystem-local)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40029.5M87](/packages/league-flysystem-bundle)[league/flysystem-sftp-v3

SFTP filesystem adapter for Flysystem.

6129.6M91](/packages/league-flysystem-sftp-v3)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)

PHPackages © 2026

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