PHPackages                             uecode/segment-io-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. uecode/segment-io-php

ActiveLibrary

uecode/segment-io-php
=====================

A PHP library for reporting events to the Segment.io API

1.2.0(9y ago)218.1k8[2 issues](https://github.com/uecode/segment-io-php/issues)MITPHPPHP &gt;=5.5

Since Aug 2Pushed 9y ago5 watchersCompare

[ Source](https://github.com/uecode/segment-io-php)[ Packagist](https://packagist.org/packages/uecode/segment-io-php)[ Docs](http://segment.io)[ RSS](/packages/uecode-segment-io-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (8)Versions (6)Used By (0)

Segment PHP Client
==================

[](#segment-php-client)

[![Build Status](https://camo.githubusercontent.com/856aa557fe4be068e71c6c23a17ac7bb646c82fa0c3adb09cd0a617e3cf5b5ef/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7565636f64652f7365676d656e742d696f2d7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/uecode/segment-io-php)[![Quality Score](https://camo.githubusercontent.com/b8bde9a21c96ee20f0ae70b86f7d351dd17933d51ab40346eb4885176e23416c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7565636f64652f7365676d656e742d696f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/uecode/segment-io-php/)[![Code Coverage](https://camo.githubusercontent.com/7462d0ee871d89543885d7632fb98b7ffb3b80e12126d598523a0c647360e38a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7565636f64652f7365676d656e742d696f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/uecode/segment-io-php/)[![Total Downloads](https://camo.githubusercontent.com/d2d9422bc3937677a523a4b6c0ab75eea28d05915a6dd00fcffa8b52573a3e97/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7565636f64652f7365676d656e742d696f2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uecode/segment-io-php)

This library provides a Web Service Client for the Segment.io HTTP API using [Guzzle v5](http://guzzle.readthedocs.org/en/5.3/).

### Installation

[](#installation)

Installation

Install the latest version with:

```
$ composer require uecode/segment-io-php ~1.1
```

### Basic Usage

[](#basic-usage)

```
use SegmentIO\Client;

$client = new Client(['write_key' => $writeKey]);

// Identify the user - assuming, below, that you
// have a $user object from your database
$client->identify([
    'userId' => $user->getId(),
    'traits' => [
        'name' => $user->getName(),
        'email' => $user->getEmail()
    ]
]);

// Track an event (userId or anonymousId is required for all events!)
$client->track([
    'userId' => $user->getId(),
    'event'  => 'Some Event Happened',
    'properties' => [
        'foo' => 'bar'
    ]
]);
```

### Configuration Options

[](#configuration-options)

The client accepts an array of configuration options:

SettingProperty NameDescriptionAPI Write Key`write_key`The Segment.io API Write KeyAPI Version`version`The API Version. Used to version the API (default: `v1`)Batching`batching`A method of batching calls to the API to reduce latency of over the wire requests (supports: `request` or `file`) - use `false` to disableRequest Batching: Max Queue Size`max_queue_size`When using Request Batching, this is the total amount of Events to queue before flushingRequest Batching: Batch Size`batch_size`When using Request Batching, this is the total amount of Events sent in a single RequestFile Batching: Log File`log_file`When using File Batching, this determines what file to log Events to### Using Batching

[](#using-batching)

By default, this client will attempt to queue all calls to the API and send them out over a single batch request. Because of the blocking nature of PHP, this method reduces the amount of time the Client has to wait for requests to the API.

Batching does not apply to the `import()` method on the client.

There are two methods of Batching Available:

#### Request Batching

[](#request-batching)

**Note**: This is enabled by default.

When making calls to the API, the events will be placed into a queue and will be flushed under one of two cases: when / if the `max_queue_size` is reached or at the end of the PHP Request.

Changing the Client options for `max_queue_size` and `batch_size` will affect how often the Client attempts to flush events.

#### File Batching

[](#file-batching)

The file batching is a more performant method for making requests to Segment.io.

Each time a track or identify call is made, it will record that call to a log file. The log file is then uploaded “out of band” by running the included `parse`command.

You can change the location of the log file by using the `log_file` Client configuration option. If a log\_file is not specified, it will default to: `/tmp/segment-io.log`.

To upload the Events from the log file to Segment.io, run the included `parse`command:

```
./parse YOUR_WRITE_KEY --file /tmp/segment-io.log

```

### Tracking HTTP API Documentation

[](#tracking-http-api-documentation)

Documentation is available for the Tracking HTTP API at [segment.io/docs/tracking-api/](https://segment.io/docs/tracking-api/reference/).

License
-------

[](#license)

This software is released under the MIT License. See the [license file](LICENSE.md) for details.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~251 days

Total

5

Last Release

3303d ago

PHP version history (2 changes)1.0.0PHP ~5.4

1.2.0PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/84ad9179e2241e556ef5d5155b3ec773d40562d325d4f9106c01af365a080a8d?d=identicon)[kmfk](/maintainers/kmfk)

---

Top Contributors

[![k-k](https://avatars.githubusercontent.com/u/2430033?v=4)](https://github.com/k-k "k-k (5 commits)")[![vViktorPL](https://avatars.githubusercontent.com/u/2961541?v=4)](https://github.com/vViktorPL "vViktorPL (1 commits)")[![zak956](https://avatars.githubusercontent.com/u/926488?v=4)](https://github.com/zak956 "zak956 (1 commits)")

---

Tags

analyticssegmentiosegment

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uecode-segment-io-php/health.svg)

```
[![Health](https://phpackages.com/badges/uecode-segment-io-php/health.svg)](https://phpackages.com/packages/uecode-segment-io-php)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.4k37.3k](/packages/matomo-matomo)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19562.3M1.3k](/packages/drupal-core)[segmentio/analytics-php

Segment Analytics PHP Library

25621.5M25](/packages/segmentio-analytics-php)

PHPackages © 2026

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