1. Go to this page and download the library: Download sineflow/clamav library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sineflow / clamav example snippets
$scanner = new Scanner(new ScanStrategyClamdUnix($socket));
$scanner = new Scanner(new ScanStrategyClamdNetwork($host, $port));
use Sineflow\ClamAV\Scanner;
use Sineflow\ClamAV\Exception\FileScanException;
use Sineflow\ClamAV\Exception\SocketException;
public function myAction(Scanner $scanner)
{
try {
$scannedFile = $scanner->scan($file);
if (!$scannedFile->isClean()) {
echo $scannedFile->getVirusName();
}
} catch (SocketException $e) {
...
} catch (FileScanException $e) {
...
}
}
use Sineflow\ClamAV\Scanner;
use Sineflow\ClamAV\Exception\FileScanException;
use Sineflow\ClamAV\Exception\SocketException;
// In a real application, the stream would typically come from
// Flysystem's readStream(), an HTTP response, or similar source.
public function myAction(Scanner $scanner)
{
$stream = fopen('/path/to/file', 'rb');
try {
$scannedFile = $scanner->scanStream($stream, 'my-upload.pdf');
if (!$scannedFile->isClean()) {
echo $scannedFile->getVirusName();
}
} catch (SocketException $e) {
...
} catch (FileScanException $e) {
...
} finally {
fclose($stream);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.