PHP code example of cakedc / cakephp-clamav

1. Go to this page and download the library: Download cakedc/cakephp-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/ */

    

cakedc / cakephp-clamav example snippets


\Cake\Core\Configure::write('CakeDC/Clamav', [
    // WARNING, disabling will SKIP virus check in validation rules
    'enabled' => true,
    // clamd listening in this socket, defaults to unix file socket
    'socketConfig' => [
        'host' => 'unix:///var/run/clamav/clamd.ctl',
        'port' => null,
        'persistent' => true
    ],
]);

if (Configure::read('CakeDC/Clamav.enabled')) {
            if (!$validator->getProvider('clamd')) {
                $validator->setProvider('clamd', new ClamdValidation());
            }
            $validator->add(
                'attachment',
                'noVirus',
                [
                    'rule' => 'fileHasNoVirusesFound',
                    'provider' => 'clamd',
                ]
            );
        }