1. Go to this page and download the library: Download adriengras/php-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/ */
adriengras / php-clamav example snippets
use AdrienGras\PhpClamAV\ClamAV;
# with a TCP socket
$client = new ClamAV::fromDSN('tcp://localhost:3310');
# or with host and port
$client = new ClamAV::fromParts('localhost', '3310');
# or with a Unix socket
$client = new ClamAV::fromDSN('unix:///var/run/clamav/clamd.sock');
# Ping the daemon, returns true if the daemon is alive, false otherwise
$isPingable = $client->ping();
# Get the ClamAV version
$version = $client->version();
# Reload the database
$client->reload();
# Scan a file, returns true if the file is clean, false otherwise
$result = $client->scan('/path/to/file.txt');
# Scan a directory, returns true if all the files are clean, false otherwise
$infectedFiles = $client->scan('/path/to/directory');
# Scan a stream, returns true if the stream is clean, false otherwise
# You can either pass a resource or a string. If you pass a string, the method will create a temporary stream.
$stream = fopen('/path/to/file.txt', 'r');
$result = $client->scanInStream($stream);
# or
$fileToStream = '/path/to/file.txt';
$result = $client->scanInStream($fileToStream);
# Scan and continue if a virus is found.
# The method will return an array of infected files, or an empty array if no virus is found.
$result = $client->continueScan('/path/to/directory');
# Shutdown the daemon
$client->shutdown();
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.