Translate client demo for PHP 5.6

Implementing PHP translation clients is very simple, the configuration process as below:

Install zmq for php extension

pecl install zmq-beta

edit php.ini, and then add:

extension=zmq.so

notes: do not compile the source code of zmq-php, there will got a lot of compilation errors.

The simple demo PHP script:

<?php

$src   =  "this is my php";    
$host  =  "192.168.1.5";
$port  =  "5566";

$json_src = '[{"src": "".$src.""}]';

$context    =  new ZMQContext();
$requester =  new ZMQSocket($context, ZMQ::SOCKET_REQ);
$requester->connect("tcp://".$host.":".$port."");

$requester->send($json_src); //send src to translate server
$reply = $requester->recv();

echo $reply; 

?>
1 Like