Protocol buffers is a lightweight and efficient structured data storage format that can be used for structured data serialization and is ideal for data storage or RPC data interchange formats. It can be used in communication protocol, data storage and other fields of the language-independent, platform-independent, extensible serialization structure data format. Currently, only APIs in three languages, C + +, Java, and Python are available. Through the php-protobuf can be achieved, the following is my installation experience.
1.centos Environment
centos6.8
2.php Environment
php-5.5.30
Path
/usr/local/php-5.5.30
Install the PROTOBUF and Php-protobuf-master under/usr/local.
Apache
/usr/local/httpd
3. Dependent Package Installation
Yum-y Install php-pear php5-dev autoconf automake libtool make gcc gcc-c++
4. Installing PROTOBUF
Protobuf-2.4.1.tar.gz
wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.bz2
TAR-JXVF protobuf-2.4.1.tar.bz2
CD PROTOBUF-2.4.1/
./configure--with-php-config=/usr/local/php-5.5.30/bin/php-config
Make
Make install
5.master Installation
Master.zip
wget Https://github.com/allegro/php-protobuf/archive/master.zip
Unzip Master.zip
CD Php-protobuf-master
/usr/local/php/bin/phpize #生成configure
./configure
Make
Make install
Results show/usrb64/php/modules/indicates successful installation
ll/usrb64/php/modules/
Vi/usr/local/php/etc/php.ini
Add to:
Extension=/usr/lib64/php/modules/protobuf.so
Restart Apache Service httpd restart
6. Execute Statement Validation Results
Below this file path, the Test.proto,vitest.proto content is as follows:
----------------------------------------------
Message PhoneNumber {
Required String number = 1;
Required Int32 type = 2;
}
Message person {
Required String name = 1;
Required Int32 id = 2;
Optional String email = 3;
Repeated PhoneNumber phone = 4;
Optional double money = 5;
}
Message AddressBook {
Repeated person person = 1;
}
-------------------------------
Protoc--plugin=/usr/local/php/bin/protoc-gen-php--php_out=. -I. Tes1t.proto
Generating the test.php file indicates success.
Reference Connection Address:
Http://www.hello1010.com/php-protobuf
Http://www.cnblogs.com/brookin/p/4423692.html
Http://www.cnblogs.com/taek/p/5470693.html
Compilation of Php-protobuf