1This directory contains the Protocol Buffers runtime implementation via both a 2pure PHP package and a native c extension. The pure PHP package is intended to 3provide usability to wider range of PHP platforms, while the c extension is 4intended to provide higher performance. Both implementations provide the same 5runtime APIs and share the same generated code. Users don’t need to re-generate 6code for the same proto definition when they want to switch the implementation 7later. 8 9Both implementations make use of generated PHP code that defines message and 10enum types in PHP. We strongly recommend using protoc's PHP generation support 11with .proto files. The build process in this directory only installs the 12extension/package; you need to install protoc as well to have PHP code 13generation functionality. 14 15## Requirements 16 17To use PHP runtime library requires: 18 19- C extension: PHP 5.5, 5.6, or 7. 20- [PHP package](http://php.net/downloads.php): PHP 5.5, 5.6 or 7. 21 22## Installation 23 24### C Extension 25 26#### Prerequirements 27 28To install the c extension, the following tools are needed: 29* autoconf 30* automake 31* libtool 32* make 33* gcc 34* pear 35* pecl 36 37On Ubuntu, you can install them with: 38``` 39sudo apt-get install -y php-pear php5-dev autoconf automake libtool make gcc 40``` 41On other platforms, please use the corresponding package managing tool to 42install them before proceeding. 43 44#### Installation from Source (Building extension) 45 46To build the c extension, run the following command: 47``` 48cd ext/google/protobuf 49pear package 50sudo pecl install protobuf-{VERSION}.tgz 51``` 52 53#### Installation from PECL 54 55When we release a version of Protocol Buffers, we will upload the extension to 56[PECL](https://pecl.php.net/). To use this pre-packaged extension, simply 57install it as you would any other extension: 58 59``` 60sudo pecl install protobuf-{VERSION} 61``` 62 63### PHP Package 64 65#### Installation from composer 66 67Simply add "google/protobuf" to the 'require' section of composer.json in your 68project. 69 70### Protoc 71 72Once the extension or package is installed, if you wish to generate PHP code 73from a `.proto` file, you will also want to install the Protocol Buffers 74compiler (protoc), as described in this repository's main `README` file. The 75version of `protoc` included in the latest release supports the `--php_out` 76option to generate PHP code: 77``` 78protoc --php_out=out_dir test.proto 79``` 80 81## Usage 82 83For generated code: 84 https://developers.google.com/protocol-buffers/docs/reference/php-generated 85 86Known Issues 87------------ 88 89* Missing native support for well known types. 90* Missing support for proto2. 91* No API provided for clear/copy messages. 92* No API provided for encoding/decoding with stream. 93* Map fields may not be garbage-collected if there is cycle reference. 94* No debug information for messages in c extension. 95* HHVM not tested. 96* C extension not tested on windows, mac, php 7.0. 97* Message name cannot be Empty. 98