PHPackages                             thinkfluent/fanfan-client-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. thinkfluent/fanfan-client-php

ActiveLibrary[API Development](/categories/api)

thinkfluent/fanfan-client-php
=============================

PHP Client for FanFan - a Serverless Fan-out, Fan-in Framework for Google Cloud Pub/Sub

v1.1.1(1y ago)111.6k↓62.6%MITPHPPHP &gt;=7.4

Since Jul 10Pushed 1y agoCompare

[ Source](https://github.com/thinkfluent/fanfan-client-php)[ Packagist](https://packagist.org/packages/thinkfluent/fanfan-client-php)[ RSS](/packages/thinkfluent-fanfan-client-php/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

PHP Client for FanFan - a Serverless Fan-out, Fan-in Framework for Google Cloud Pub/Sub
=======================================================================================

[](#php-client-for-fanfan---a-serverless-fan-out-fan-in-framework-for-google-cloud-pubsub)

[![CI Tests](https://github.com/thinkfluent/fanfan-client-php/actions/workflows/tests.yaml/badge.svg)](https://github.com/thinkfluent/fanfan-client-php/actions/workflows/tests.yaml)

For more detail on FanFan, see the main project here: [thinkfluent/fanfan](https://github.com/thinkfluent/fanfan)

If you want to see a working demo application, see this project: [thinkfluent/fanfan-demo-php](https://github.com/thinkfluent/fanfan-demo-php)

Installation
------------

[](#installation)

```
composer require thinkfluent/fanfan-client-php
```

Usage
-----

[](#usage)

I recommend you review &amp; understand the message &amp; workflow concepts first here: [thinkfluent/fanfan](https://github.com/thinkfluent/fanfan)

### Create a Fan-out Job

[](#create-a-fan-out-job)

Note: The `fanfan-client-php` library does not require or operate on the the Google Pub/Sub client package. You will need to include that yourself, and emit messages to it.

```
use FanFan\Client\Message\JobRequest;
use Google\Cloud\PubSub\PubSubClient;

// Prepare a JobRequest
$jobRequest = (new JobRequest())
    ->action('process_order')
    ->forEach('order', [4, 2, 19, 79]);

// Send to FanFan (via Pub/Sub)
$jobRequestTopic = (new PubSubClient())->topic('projects/get-fanfan/topics/fanfan-job-request');
$jobRequestTopic->publish($jobRequest->formatForPubSub());
```

### Execute a Single Fanned-out Task &amp; Emit Response

[](#execute-a-single-fanned-out-task--emit-response)

Using a simple "HTTP Push" subscription. Your application will receive 1-many requests like this

```
use FanFan\Client\Message\Builder\TaskBuilder;
use Google\Cloud\PubSub\PubSubClient;

// Grab the Task data from the POST body (most of this is extracting the base64 message from the Pub/Sub payload)
// Your framework of choice may well have tooling to support you with this (Like PSR-7 Requests)
$payload = \json_decode(\file_get_contents('php://input'), false, 512, JSON_THROW_ON_ERROR);
$messageData = \json_decode(\base64_decode($payload->message->data), false, 512, JSON_THROW_ON_ERROR);

// Build `FanFan\Client\Message\Task`, contains instructions & payload for ONE fanned-out task
$task = TaskBuilder::fromPubSub($messageData);

// ...do work here...
// e.g. switch on $task->getAction(), use the data from $task->getPayload();

// Create & publish the Task outcome
$outcome = $task->createOutcome(TaskStatus::SUCCEEDED);
$jobRequestTopic = (new PubSubClient())->topic('projects/get-fanfan/topics/fanfan-task-done');
$jobRequestTopic->publish($outcome->formatForPubSub());
```

### Receive Job Outcome

[](#receive-job-outcome)

```
use FanFan\Client\Message\Builder\JobOutcomeBuilder;
// Extract Pub/Sub message into `$messageData` as per above example
$payload = \json_decode(\file_get_contents('php://input'), false, 512, JSON_THROW_ON_ERROR);
$messageData = \json_decode(\base64_decode($payload->message->data), false, 512, JSON_THROW_ON_ERROR);

// Build `FanFan\Client\Message\JobOutcome`
$outcome = JobOutcomeBuilder::fromPubSub($messageData);

// Work with the output
echo $outcome->getStatus(), PHP_EOL;
echo $outcome->getTaskCounts()['SUCCEEDED'], PHP_EOL;
echo $outcome->getTaskCounts()['FAILED'], PHP_EOL;
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance41

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~298 days

Total

3

Last Release

494d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/afcf8354eefa121c96ee96eeb07d0d6ab5c30216632c5b53e420d9760748d8c4?d=identicon)[thinkfluent](/maintainers/thinkfluent)

---

Top Contributors

[![tomwalder](https://avatars.githubusercontent.com/u/1258131?v=4)](https://github.com/tomwalder "tomwalder (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thinkfluent-fanfan-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/thinkfluent-fanfan-client-php/health.svg)](https://phpackages.com/packages/thinkfluent-fanfan-client-php)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
