Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Build Status

nanomsg extension for PHP

For more information about nanomsg see:

How to install

  1. Install nanomsg library, see:
  2. Install PHP dev tools for extension: sudo apt-get install php5-dev (for Debian/Ubuntu) or sudo yum install php-devel (Fedora)
  3. Clone repo at your server, e.g. cd /var/tmp && git clone
  4. cd /var/tmp/php-nano
  5. phpize
  6. configure --enable-nano
  7. make
  8. make install
  9. Edit your php.ini file, add
  10. Restart FPM service or Apache web server.

!Note! tested with PHP 5.6.2 only ( PHP_VERSION : 5.6.9-0+deb8u1 ZEND_VERSION: 2.6.0 ). PHP must support Namespace (PHP 5 >= 5.3.0, see:

Base classes and methods

php-nano exposed namespace NanoMsg with three class:

  • NanoMsg\Nano - main class
  • NanoMsg\Socket - base socket class
  • NanoMsg\Exception - utility class for Exception

For example, use it with short name:

use NanoMsg\Nano as Nano;
use NanoMsg\Socket as NanoSocket;
use NanoMsg\Exception as NanoException;


Base class. Provide static function device (see:

Also provided some static constant:

domain of creating socket (see:

  • Nano::AF_SP - Standard full-blown SP socket
  • Nano::AF_SP_RAW - Raw SP socket. Raw sockets omit the end-to-end functionality found in AF_SP sockets and thus can be used to implement intermediary devices in SP topologies.

Protocol parameter defines the type of the socket, which in turn determines the exact semantics of the socket

Nanomsg library support 4 network/communication protocol at now:

  • inproc (e.g.: inproc://example) - for in-process low-latency communication at same machine.
  • ipc (e.g.: ipc://example) - for inter-process communication at same machine.
  • tcp (e.g.: tcp:// - for tcp communication over LAN/WAN.
  • ws (e.g.: ws:// - use WebSocket protocol over TCP. Current release, 0.5.х not supported WS, only latest build from master.

Performance note: ipc vs inproc at same machine has 2х - 4х slow (tested NN_PAIR socket), tcp vs ipc 3х - 5х slow, and ws same as tcp at performance.

For tcp and ws protocol, for bind method, valid IP (not domain name) and port required. For connect - you may use domain name as adress. More see:


Main class to provide socket.


  • bind
  • connect
  • shutdown
  • send
  • recv
  • setsockopt
  • getsockopt


PHP nanomsg







No releases published


No packages published