PHPackages                             breinify/brein-engine-api - 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. breinify/brein-engine-api

ActiveLibrary[API Development](/categories/api)

breinify/brein-engine-api
=========================

A PHP library to exchange data through the API of the Brein Engine.

1.0.3(9y ago)018MITPHPPHP ^5.0 || ^7.0

Since Dec 20Pushed 3y ago10 watchersCompare

[ Source](https://github.com/Breinify/brein-api-library-php)[ Packagist](https://packagist.org/packages/breinify/brein-engine-api)[ RSS](/packages/breinify-brein-engine-api/feed)WikiDiscussions master Synced 4w ago

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

 [![Breinify API PHP Library](https://raw.githubusercontent.com/Breinify/brein-api-library-php/master/documentation/img/logo.png)](https://raw.githubusercontent.com/Breinify/brein-api-library-php/master/documentation/img/logo.png)

Breinify's DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips.

### Step By Step Introduction

[](#step-by-step-introduction)

#### What is Breinify's DigitialDNA

[](#what-is-breinifys-digitialdna)

Breinify's DigitalDNA API puts dynamic behavior-based, people-driven data right at your fingertips. We believe that in many situations, a critical component of a great user experience is personalization. With all the data available on the web it should be easy to provide a unique experience to every visitor, and yet, sometimes you may find yourself wondering why it is so difficult.

Thanks to **Breinify's DigitalDNA** you are now able to adapt your online presence to your visitors needs and **provide a unique experience**. Let's walk step-by-step through a simple example.

Quick start
-----------

[](#quick-start)

### Step1: Configure the library

[](#step1-configure-the-library)

In order to use the library you need a valid API-key, which you can get for free at . In this example, we assume you have the following api-key:

**772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6**

```
// configure the library
$apiKey = "772A-47D7-93A3-4EA9-9D73-85B9-479B-16C6";
$breinify = new \Breinify\API\Breinify($apiKey);
```

The Breinify object is now configured with a valid configuration.

#### Step 2: Start using the library

[](#step-2-start-using-the-library)

##### Placing activity triggers

[](#placing-activity-triggers)

The engine powering the DigitalDNA API provides two endpoints. The first endpoint is used to inform the engine about the activities performed by visitors of your site. The activities are used to understand the user's current interest and infer the intent. It becomes more and more accurate across different users and verticals as more activities are collected. It should be noted, that any personal information is not stored within the engine, thus each individual's privacy is well protected. The engine understands several different activities performed by a user, e.g., landing, login, search, item selection, or logout.

```
// create a user
$user = new \Breinify\API\BreinUser();
$user.setFirstName("Diane");
$user.setLastName("Keng");
$user.setEmail("diane.keng@breinify.com");

// create an activity
$activity = new \Breinify\API\BreinActivity();
$activity.setUser($user);
$activity->addActivity("login");

// send a request
$breinify->sendActivity($activity);
```

That's it!

##### Placing temporalData triggers

[](#placing-temporaldata-triggers)

Temporal Intelligence API provides temporal triggers and visualizes patterns enabling you to predict a visitor’s dynamic activities. Currently this will cover:

- Current Weather
- Upcoming Holidays
- Time Zone
- Regional Events

They can be requested like this:

```
// create a user
$user = new \Breinify\API\BreinUser();
$user.setEmail("diane.keng@breinify.com");
$user->setLocalDateTime("Sun Dec 25 2016 18:15:48 GMT-0800 (PST)");
$user->setTimezone("America/Los_Angeles");

// create temporalData object and invoke the request
$temporalData = new \Breinify\API\BreinTemporalData();
$result = $breinify->temporalData($temporalData);
```

A more detailed introduction
----------------------------

[](#a-more-detailed-introduction)

### Requirements

[](#requirements)

This library is used to integrate the Brein Engine (more specific, the API's end-points: activity and lookup) into a given PHP based web-platform. The library requires PHP 5 or higher.

### Communicating with the Brein Engine

[](#communicating-with-the-brein-engine)

The communication with the Brein Engine can be performed from back-end side, i.e.,:

- using file-streams (i.e., url-based file-streams must be supported, see [Environment and file-streams](#using-back-end-calls-utilizing-file-streams)), or
- using cURL (i.e., PHP cURL module available, see [Environment and cURL](#using-back-end-calls-utilizing-curl)).

In addition, the communication can also be performed through injected JavaScript on client-side.

In the former case, it is necessary that the PHP back-end infrastructure allows the communication with the Brein Engine (i.e., outgoing POST-traffic should not be blocked). In the latter case, the communication with the Brein Engine might be blocked by the client. Thus, we recommend the usage of a back-end to back-end communication based on file-streams or cURL.

Troubleshooting
---------------

[](#troubleshooting)

### Using back-end calls utilizing file-streams

[](#using-back-end-calls-utilizing-file-streams)

If the communication between the back-end and the Brein Engine is performed with file-streams the back-end must fulfill the following requirements:

- POST calls to the Brein Engine must not be blocked by the firewall (i.e., outgoing traffic should be possible),
- the functions *stream\_context\_create* and *file\_get\_contents* must be available (which is the case by default since PHP 4.3.0, cf.: [PHP stream context documentation](http://php.net/manual/en/function.stream-context-create.php), [PHP file get contents documentation](http://php.net/manual/en/function.file-get-contents.php)), and
- the ini-parameter *allow\_url\_fopen* must be set to ON in the *php.ini* (which is the default setting, cf.: [PHP file system documentation](http://php.net/manual/en/filesystem.configuration.php))

### Using back-end calls utilizing cURL

[](#using-back-end-calls-utilizing-curl)

If the communication between the back-end and the Brein Engine is performed using cURL the back-end must fulfill the following requirements:

- POST calls to the Brein Engine must not be blocked by the firewall (i.e., outgoing traffic should be possible), and
- the [cURL](http://php.net/manual/en/book.curl.php) module must be available, i.e., the functions *curl\_init*, *curl\_setopt*, *curl\_exec*, *curl\_getinfo*, and *curl\_close* must be available.

IDE Configuration
-----------------

[](#ide-configuration)

Further information regarding the configuration of the IDE can be found [here](./documentation/devenv.md).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 56.9% 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 ~9 days

Total

4

Last Release

3448d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eed478cad1cb7f16348c84647b7dbf56291ca303da62b700073b89a1b88f84c8?d=identicon)[Breinify Staging](/maintainers/Breinify%20Staging)

---

Top Contributors

[![pmeisen](https://avatars.githubusercontent.com/u/2893215?v=4)](https://github.com/pmeisen "pmeisen (37 commits)")[![MarcoRecchioni](https://avatars.githubusercontent.com/u/1072298?v=4)](https://github.com/MarcoRecchioni "MarcoRecchioni (18 commits)")[![havenwang](https://avatars.githubusercontent.com/u/5884125?v=4)](https://github.com/havenwang "havenwang (10 commits)")

---

Tags

breinifybrein enginecollective intelligence

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/breinify-brein-engine-api/health.svg)

```
[![Health](https://phpackages.com/badges/breinify-brein-engine-api/health.svg)](https://phpackages.com/packages/breinify-brein-engine-api)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

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

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

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

PHPackages © 2026

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