ndrstmr/icap-flow

State-of-the-art, async-ready ICAP client for PHP.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ndrstmr/icap-flow

v1.0.0 2025-06-18 22:36 UTC

This package is auto-updated.

Last update: 2026-01-08 00:00:22 UTC


README

IcapFlow Logo

Latest Stable Version Total Downloads GitHub Actions Workflow Status Code Coverage PHPStan Level License

icap-flow

A modern, robust, and async-ready ICAP (Internet Content Adaptation Protocol) client for PHP 8.3+.

Project Vision

This library aims to be the de-facto standard solution for PHP developers needing ICAP connectivity, focusing on quality, performance, and an excellent developer experience. For more details, see our mission charter.

Installation

composer require ndrstmr/icap-flow

Basic Usage

For most projects, the SynchronousIcapClient offers a very simple, blocking API.

$icap = SynchronousIcapClient::create();

$result = $icap->scanFile('/service', '/path/to/your/file.txt');

echo $result->isInfected()
    ? 'Virus found: ' . $result->getVirusName()
    : 'File is clean';

Advanced Usage: Asynchronous Requests

To take advantage of non-blocking I/O, interact with the IcapClient directly within an event loop:

use Revolt\EventLoop;

$icap = IcapClient::create();

EventLoop::run(function () use ($icap) {
    $future = $icap->scanFile('/service', '/path/to/your/file.txt');
    $result = $future->await();

    echo $result->isInfected()
        ? 'Virus: ' . $result->getVirusName() . PHP_EOL
        : 'File is clean' . PHP_EOL;
});

Configuration

Adjust the connection settings using the Config DTO:

use Ndrstmr\Icap\Config;

$config = new Config(
    host: 'icap.example.com',
    port: 1344,
    socketTimeout: 5.0,
    streamTimeout: 30.0,
    // Header used by the ICAP server to report infections
    virusFoundHeader: 'X-Virus-Name',
);

This object can be passed to the client factory methods.

Extensibility (Cookbook)

Preview handling uses the Strategy pattern. Custom strategies implement PreviewStrategyInterface and can be registered on the client. Detailed examples can be found in the examples/cookbook/ directory.

For Developers

Run the test suite with the following command:

composer test

Further details about the pull request workflow can be found in CONTRIBUTING.md.

License

This project is licensed under the EUPL-1.2 License. See the LICENSE file for details.

Changelog

A list of all changes can be found in CHANGELOG.md.