Compilation of Php-protobuf

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.