A custom Laravel virus validator based on ClamAV anti-virus scanner for file uploads.
You must have ClamAV anti-virus scanner running on the server to make this package work.
You can see the ClamAV installation instructions on the official ClamAV documentation.
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.
1. Install the package through Composer.
$ composer require sunspikes/clamav-validator
This package supports Laravel new Package Discovery.
If you are using Laravel < 5.5, you need to add Sunspikes\ClamavValidator\ClamavValidatorServiceProvider::class
to your providers
array in config/app.php
:
'providers' => [
// ...
Sunspikes\ClamavValidator\ClamavValidatorServiceProvider::class,
],
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.
If you want to customize the translation or add your own language you can run the 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 resources/lang/vendor/clamav-validator
for Laravel >= 5.1
Use it like any Validator
rule:
$rules = [
'file' => 'clamav',
];
Krishnaprasad MG [@sunspikes] and other awesome contributors