PHPackages                             bam/php-publisher - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bam/php-publisher

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bam/php-publisher
=================

PHP data publisher for BAM

1.0.0(11y ago)0221Apache License 2.0PHP

Since Dec 19Pushed 4y ago1 watchersCompare

[ Source](https://github.com/omindu/bam-php-publisher)[ Packagist](https://packagist.org/packages/bam/php-publisher)[ Docs](https://github.com/omindu/bam-php-publisher)[ RSS](/packages/bam-php-publisher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

PHP Publisher for BAM
=====================

[](#php-publisher-for-bam)

The PHP data publisher allows PHP clients to publish data to [WSO2 Business Activity Monitor](http://wso2.com/products/business-activity-monitor/). The data can be published to predefined or custom set of data fields. The functionality of the PHP data publisher is analogous to the functionality of a custom java data publisher

The publisher uses [Apache Thrift](https://thrift.apache.org/) to publish data sent by the PHP client to the BAM server. The publisher exposes the client to operations such as defining data streams, searching stream definitions and publishing events.

Read more on data streams and publishing data to WSO2 BAM

- [Data Publisher](https://docs.wso2.com/display/BAM241/Data+Publisher)
- [Stream Definitions](http://maninda.blogspot.com/2012/10/stream-definitions.html)
- [Creating Custom Data Publishers to BAM/CEP](http://wso2.com/library/articles/2012/07/creating-custom-agents-publish-events-bamcep/)

Prerequisites
-------------

[](#prerequisites)

- PHP 5.5.x or above
- WSO2 BAM 2.4.1 or above

Dependancies
------------

[](#dependancies)

- [Apache log4php](http://logging.apache.org/log4php/index.html) v2.3.0
- [Apache Thrift](https://thrift.apache.org/) v0.9

Getting Started
---------------

[](#getting-started)

### Installing the Publisher

[](#installing-the-publisher)

The recommended way of installing the Publisher is via [Composer](https://getcomposer.org/).

The BAM PHP publisher is added to the [Packagist](https://packagist.org/) archive. Therefore the publisher can be installed to a project by including it as a dependency in `Composer.json`. When installing via Composer, log4php and thrift dependencies will be automatically installed to the project.

```
{
    "require": {
        "omindu/php-publisher": "1.0.0"
    }
}
```

### Sample Publisher Client

[](#sample-publisher-client)

```
$receiverURL = 'tcp://10.100.5.198:7761';
$authenticationURL = 'https://localhost:9443';
$username = 'admin';
$password = 'admin';

$verifyPeer = true;
$caFile = '/absolute/path/to/certificate.pem';

try {

    //Set configuration properties for the publisher
    $config = new PublisherConfiguration($verifyPeer, $caFile);

    //Initializing a Publisher object
    $publisher = new Publisher($receiverURL, $username, $password, $authenticationURL, $config);

    //JSON formatted stream definition
	$streamDefinition = "{ 'name':'sample.stream', "
			             ."'version':'1.0.0', "
			             ."'nickName':'Sample Saream Definition',"
			             ."'description':'This is a description',"
			             ."'metaData':[{'name':'metaField1','type':'STRING'}],"
			             ."'correlationData':[{'name':'corrField1','type':'STRING'}],"
					     ."'payloadData':[{'name':'payloadField1','type':'STRING'},"
					                       ."{'name':'payloadField2','type':'DOUBLE'},"
					                       ."{'name':'payloadField3','type':'STRING'},"
						                   ."{'name':'payloadField4','type':'INT'} ] }";

	//Adding the strem definition to BAM
	$streamId = $publisher->defineStream($streamDefinition);

	//Searching a stream definition
	$streamId =  $publisher->findStream( 'sample.stream', '1.0.0' );

    //Initializing an Event object
    $event = new Event($streamId, time());

    //Setting up event attributes. The of each array should follow the data type and order of the stream definiiton
	$metaData = ['meta1'];
	$correlationData = ['corr1'];
	$payloadData = ['pay1',pi(),'pay2',888];
	$arbitraryDataMap = ['x'=>'arb1','y'=>'arb2'];

	//Adding the attributes to the Event object
	$event->setMetaData($metaData);
	$event->setCorrelationData($correlationData);
	$event->setPayloadData($payloadData);
	$event->setArbitraryDataMap($arbitraryDataMap);

    //Publish the event to BAM
	$publisher->publish($event);

}catch(Exception $e){
    //To see the exception types supported by the publisher, refer the API section
    print_r($e->getTrace());
}
```

API
---

[](#api)

#### `class Publisher`

[](#class-publisher)

```
function __construct($receiverURL, $username, $password, $authenticationURL)

    @param string $receiverURL
    @param string $username
    @param string $password
    @param string $authenticationURL - @default null

function findStreamId($streamName, $streamVersion)

    @param string $streamName
    @param string $streamVersion
    @return string $streamId
    @throws NoStreamDefinitionExistException

function defineStream($streamDefinision)

    @param string $streamDefinision
    @return string $streamId
    @throws StreamDefinitionException
    @throws DifferentStreamDefinitionAlreadyDefinedException
    @throws MalformedStreamDefinitionException

function publish($event)
    @param Event $event
    @throws UnknownEventAttributeException
```

#### `class PublisherConfiguration`

[](#class-publisherconfiguration)

```
function __construct($verifyPeer, $caFile)

    @param boolean $verifyPeer - @default false
    @param string $caFile - @default null
    @throws NullPointerException

function setVerifyPeer($verifyPeer)
    @param boolean $verifyPeer

function getVerifyPeer()
    @return boolean $verifyPeer

function setCaFile($caFile)
    @param string $caFile

function getCaFile()
    @return string $caFile
```

#### `class Event`

[](#class-event)

```
function __construct($streamId, $timeStamp, $metaData , $correlationData, $payloadData , $arbitraryDataMap)

    @param string $streamId - @default null
    @param string $timeStamp - @default null
    @param string $metaData - @default null
    @param array $correlationData - @default null
    @param array $payloadData - @default null
    @param array $arbitraryDataMap - @default null

function getStreamId()
    @return string $streamId

function setStreamId($streamId)
    @param string $streamId

function getTimeStamp()
    @return long $timeStamp

function setTimeStamp($timeStamp)
    @param long $timeStamp

function getMetaData()
    @return array $metaData

function setMetaData($metaData)
    @param array $metaData

function getCorrelationData()
    @return array $correlationData

function setCorrelationData($correlationData)
    @param array $correlationData

function getPayloadData()
    @return array $payloadData

function setPayloadData($payloadData)
    @param array $payloadData

function getArbitraryDataMap()
    @return array $arbitraryDataMap

function setArbitraryDataMap($arbitraryDataMap)
    @param array $arbitraryDataMap

```

License
-------

[](#license)

[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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

Unknown

Total

1

Last Release

4167d ago

### Community

Maintainers

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

---

Top Contributors

[![omindu](https://avatars.githubusercontent.com/u/9883427?v=4)](https://github.com/omindu "omindu (16 commits)")

---

Tags

WSO2BAMdata publisher

### Embed Badge

![Health badge](/badges/bam-php-publisher/health.svg)

```
[![Health](https://phpackages.com/badges/bam-php-publisher/health.svg)](https://phpackages.com/packages/bam-php-publisher)
```

PHPackages © 2026

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