PHPackages                             migratorydata/migratorydata-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. [HTTP &amp; Networking](/categories/http)
4. /
5. migratorydata/migratorydata-client-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

migratorydata/migratorydata-client-php
======================================

MigratoryData Client API for PHP

6.0.5(1y ago)125.4k↓28.6%proprietaryPHPPHP &gt;=5.3.0

Since Jun 3Pushed 1y ago1 watchersCompare

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

READMEChangelog (4)DependenciesVersions (9)Used By (0)

MigratoryData Client for PHP 5.x &amp; 6.x
==========================================

[](#migratorydata-client-for-php-5x--6x)

Below you can find a tutorial and usage example. For more information please refer to [MigratoryData Documentation 6.x](https://migratorydata.com/docs/client-api/php/).

Usage
-----

[](#usage)

Install the MigratoryData client library **5.x** using composer (MigratoryData client version 5 can be used with MigratoryData Server 5.0.\*):

```
composer require migratorydata/migratorydata-client-php:5.*
```

Install the MigratoryData client library **6.x** using composer (MigratoryData client version 6 can be used with the MigratoryData server 6.0.1 or later):

```
composer require migratorydata/migratorydata-client-php:6.*
```

Create a MigratoryData client:

```
require __DIR__ . '/vendor/autoload.php';

use MigratoryData\Client\MigratoryDataClient;
use MigratoryData\Client\MigratoryDataMessage;

$client = new MigratoryDataClient();
```

Initialize the MigratoryData client:

```
$client->setEntitlementToken("some-token");
$client->setServers(array("http://127.0.0.1:8800"));

// call connect for client API for PHP v6
$client->connect();
```

Publish a message to MigratoryData server:

```
$message = new MigratoryDataMessage("/server/status", time());
$response = $client->publish($message);
```

Example client application
--------------------------

[](#example-client-application)

Copy the code below to a file named `echo-time-client.php` and run it using the following command:

```
php echo-time-client.php
```

Example for Client API for **PHP V5**The client application connects to the MigratoryData server deployed at `localhost:8800` and publishes a message every second on the subject `/server/status`.

If you don't have a MigratoryData server installed on your machine but there is docker installed you can run the following command to start MigratoryData server, otherwise you can download and install the latest version for your os from [here](https://migratorydata.com/downloads/migratorydata-6/).

```
docker pull migratorydata/server:latest
docker run -d --name my_migratorydata -p 8800:8800 migratorydata/server:latest
```

```
