About how to compile and install msgpack-php

藏色散人
Release: 2023-04-08 09:14:01
forward
3522 people have browsed it

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
Copy after login

Unzip

tar -zxvf msgpack-2.0.3.tar.gz
 
cd msgpack-php-msgpack-2.0.3/
Copy after login

ViewphpizeFile path

$ whereis phpize
phpize: /usr/local/php-7.2.9/bin/phpize
Copy after login

Compile from source code

$./configure
$make && make install
Copy after login

Modify configuration file

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

Restartphp-fpm Check whether the installation is successful

sudo systemctl restart php-fpm.service
Copy after login

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);
Copy after login

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)
}
Copy after login

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!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template