Quahog is a simple PHP library to interface with the clamd anti-virus daemon. It was written as all of the libraries out
there for interfacing with ClamAV from PHP use exec('clamscan')
, which isn't exactly an ideal solution, as
clamscan
loads the entire database into memory each time it is run - this doesn't, so it scans a lot (lot!) faster.
It is recommended to install Quahog through composer.
{
"require": {
"xenolope/quahog": "2.*"
}
}
// Create a new socket instance
$socket = (new \Socket\Raw\Factory())->createClient('unix:///var/run/clamav/clamd.ctl');
// Create a new instance of the Client
$quahog = new \Xenolope\Quahog\Client($socket);
// Scan a file
$result = $quahog->scanFile('/tmp/virusfile');
// Scan a file or directory recursively
$result = $quahog->contScan('/tmp/virusdirectory');
// Scan a file or directory recursively using multiple threads
$result = $quahog->multiscanFile('/tmp/virusdirectory');
// Scan a stream, and optionally pass the maximum chunk size in bytes
$result = $quahog->scanStream(file_get_contents('/tmp/virusfile'), 1024);
// Scan multiple files in a row
$quahog->startSession();
$result = $quahog->scanFile('/tmp/virusfile');
$result2 = $quahog->scanFile('/tmp/virusfile2');
$quahog->endSession();
// Ping clamd
$result = $quahog->ping();
// Get ClamAV version details
$result = $quahog->version();
// View statistics about the ClamAV scan queue
$result = $quahog->stats();
// Reload the virus database
$quahog->reload();
// Shutdown clamd cleanly
$quahog->shutdown();
To run the test suite you will need PHPUnit installed. Go to the project root and run:
$ phpunit
Quahog is released under the MIT License