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. [API Development](/categories/api)
4. /
5. uecode/segment-io-php

ActiveLibrary[API Development](/categories/api)

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 3w 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

35

—

LowBetter than 77% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity30

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

3350d ago

PHP version history (2 changes)1.0.0PHP ~5.4

1.2.0PHP &gt;=5.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77113753?v=4)[kmfk](/maintainers/kmfk)[@kmfk](https://github.com/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

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[craftcms/cms

Craft CMS

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

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M572](/packages/shopware-core)

PHPackages © 2026

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