Translate client demo for PHP 5.6

(Netxiao) #1

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:

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

The simple demo PHP script:


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

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

$context    =  new ZMQContext();
$requester =  new ZMQSocket($context, ZMQ::SOCKET_REQ);

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

echo $reply;