niisan-tokyo / web-clamav-php
Anti virus scanner through web using php with clamav.
Installs: 35 016
Dependents: 1
Suggesters: 0
Security: 0
Stars: 10
Watchers: 2
Forks: 2
Open Issues: 1
Requires (Dev)
- phpunit/phpunit: ^9.2
This package is auto-updated.
Last update: 2024-12-28 11:06:20 UTC
README
We can use clamav scan through remote network by this library.
Before using this library, we prepare a remote clamav server. For example, we can use a clamav container following:
docker run -d dinkel/clamavd
Usage
Execute following code.
require 'vendor/autoload.php'; $scanner = \Niisan\ClamAV\ScannerFactory::create([ 'driver' => 'remote', 'url' => 'example.com' ]); if (! $scanner->scan($_FILE['userfile']['tmp_name'])) { echo 'User file has a virus!'; }
If a file have some virus, Scanner::scan
return false.
config
When you want know a config that is an argument of ScannerFactory, See example.config.php.
You can select driver, which 'remote' or 'local'. When yor select 'remote', the config need 'host' or 'remote.host' that means clamd host: following
[ 'driver' => 'remote', 'url' => 'examle.com' ];
[ 'driver' => 'remote' 'remote' => [ 'host' => 'example.com' ] ];
Or you select 'local', the config need 'path' or 'local.path', that means a unix socket of clamd.
[ 'driver' => 'local', 'path' => '/var/run/clamav/clamd.ctl' ]
for developing
If you want to develop this package, some tests will fail for not starting clamd server.
So you command clamd start
to start clamav daemon before testing.