PHPackages                             laruence/yar - 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. laruence/yar

ActivePhp-ext

laruence/yar
============

Light, concurrent RPC framework for PHP

1.4k0318[35 issues](https://github.com/laruence/yar/issues)[2 PRs](https://github.com/laruence/yar/pulls)CCI passing

Since Aug 1Pushed today137 watchersCompare

[ Source](https://github.com/laruence/yar)[ Packagist](https://packagist.org/packages/laruence/yar)[ RSS](/packages/laruence-yar/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Yar - Yet Another RPC framework for PHP
=======================================

[](#yar---yet-another-rpc-framework-for-php)

[![Build status](https://camo.githubusercontent.com/7ad67198e1fd4076a9948a1b5572ef41d89c0b90fc8d9f42157b49eda96c334d/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f737968773333776c74326e61643634692f6272616e63682f6d61737465723f7376673d74727565)](https://ci.appveyor.com/project/laruence/yar/branch/master) [![Build Status](https://github.com/laruence/yar/workflows/integrate/badge.svg)](https://github.com/laruence/yar/actions?query=workflow%3Aintegrate)

Light, concurrent RPC framework for PHP (see also: [Yar C framework](https://github.com/laruence/yar-c), [Yar Java framework](https://github.com/weibocom/yar-java), [Lua Yar framework](https://github.com/fangfengxiang/lua-yar))

Requirement
-----------

[](#requirement)

- PHP 7.0+ (master branch)
- PHP 5.2+ ([php5 branch](https://github.com/laruence/yar/tree/php5))
- Curl
- Json
- Msgpack (Optional)

Introduction
------------

[](#introduction)

Yar is an RPC framework which provides a simple and easy way to do communication between PHP applications. It also offers the ability to make multiple calls to remote services concurrently.

Features
--------

[](#features)

- Fast, easy, simple
- Concurrent RPC calls
- Multiple data packagers supported (php, json, msgpack built-in)
- Multiple transfer protocols supported (HTTP, HTTPS, TCP)
- Detailed debug information

Install
-------

[](#install)

### Install via PECL

[](#install-via-pecl)

Yar is a PECL extension, simply install it by:

```
$ pecl install yar
```

### Compile from source

[](#compile-from-source)

```
$ /path/to/phpize
$ ./configure --with-php-config=/path/to/php-config/
$ make && make install
```

Available configure options:

```
--with-curl=DIR
--enable-msgpack / --disable-msgpack
--enable-epoll / --disable-epoll (requires Yar 2.1.2)
```

### Install Yar with msgpack

[](#install-yar-with-msgpack)

1. Install msgpack extension for PHP:

```
$ pecl install msgpack
```

Or for Ubuntu:

```
$ apt-get install msgpack-php
```

Or, get the source from GitHub:

2. Configure with msgpack enabled:

```
$ /path/to/phpize
$ ./configure --with-php-config=/path/to/php-config/ --enable-msgpack
$ make && make install
```

Runtime Configuration
---------------------

[](#runtime-configuration)

INI SettingDefaultDescription`yar.timeout``5000`Timeout in milliseconds`yar.connect_timeout``1000`Connection timeout in milliseconds`yar.packager``"php"` (or `"msgpack"` if built with `--enable-msgpack`)One of `"php"`, `"json"`, `"msgpack"``yar.debug``Off`Enable debug mode`yar.expose_info``On`Whether to output the API info page for GET requests`yar.content_type``"application/octet-stream"`Content-Type sent in responses`yar.allow_persistent``Off`Whether to allow persistent connections> **Note**: `yar.connect_timeout` is in milliseconds. Prior to 1.2.1 it was measured in seconds.

Constants
---------

[](#constants)

```
YAR_VERSION
YAR_OPT_PACKAGER
YAR_OPT_PERSISTENT
YAR_OPT_TIMEOUT
YAR_OPT_CONNECT_TIMEOUT
YAR_OPT_HEADER          // Since 2.0.4
YAR_OPT_PROXY           // Since 2.2.0
YAR_OPT_RESOLVE         // Since 2.1.0
YAR_OPT_PROVIDER        // Since 2.3.0
YAR_OPT_TOKEN           // Since 2.3.0
```

Server
------

[](#server)

### HTTP Server

[](#http-server)

It's very easy to set up a Yar HTTP RPC Server:

```
