Home  >  Article  >  Backend Development  >  About how to compile and install msgpack-php

About how to compile and install msgpack-php

藏色散人
藏色散人forward
2020-01-21 12:21:543448browse

About how to compile and install msgpack-php

Msgpack is a PECL extension that provides an API for serialized communication with MessagePack .

MessagePack is an efficient binary-based object serialization class library that can be used for cross-language communication. It can, like JSON, exchange structural objects between many languages; but it is faster and lighter than JSON.

Download

wget https://github.com/msgpack/msgpack-php/archive/msgpack-2.0.3.tar.gz

Unzip

tar -zxvf msgpack-2.0.3.tar.gz
 
cd msgpack-php-msgpack-2.0.3/

ViewphpizeFile path

$ whereis phpize
phpize: /usr/local/php-7.2.9/bin/phpize

Compile from source code

$./configure
$make && make install

Modify configuration file

sudo vim /usr/local/php-7.2.9/etc/php.ini
 
// 增加以下扩展
extension=msgpack.so

Restartphp-fpm Check whether the installation is successful

sudo systemctl restart php-fpm.service

About how to compile and install msgpack-php

Official simple case msgpack-test.php

<?php
$data = array(0=>1,1=>2,2=>3);
$msg = msgpack_pack($data);
var_dump($data);
echo &#39;----------------&#39;;
var_dump($msg);
 
$data = msgpack_unpack($msg);
var_dump($data);

Running results

array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
----------------string(4) ""
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

For more PHP related knowledge, please visit php tutorial!

The above is the detailed content of About how to compile and install msgpack-php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete