Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Adjust formatting in readme #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 20 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@ Use

Once compiled and installed you can use it via protoc like so:

```
protoc --php_out=. your.proto
```
protoc --php_out=. your.proto

This should generate the file "your.proto.php", which should be able to encode and decode protocol buffer messages. When using the generated PHP code you must include the "protocolbuffers.inc.php" file.


Notes on Numbers
-----
----------------
PHP uses signed integers, and depending on the platform may be 32 bit or 64 bit in size. Additionally PHP is typically compiled with IEEE 754 double precision floating point numbers, but may be compiled with single precision. This causes multiple problems for PHP using large numbers. As such the best appropimation is used when an exact representation is not available. On 32 bit platforms, signed integers are correct between -2^31 and 2^31-1, outside of that range floats are used. Double precision floats maintain integer accurancy up to 2^53, beyond that integers may not be precisce.


| Proto type | PHP type (32 bit) | PHP type (64 bit)
| --------------------------------------------------------------------------------------
| bool | bool | bool
| float / double | float | float
| int32 | int | int
| int64 / uint32 | int (between -2^31 and 2^31-1) otherwise float | int
| uint64 | int (between 0 and 2^31-1) otherwise float | int (between 0 and 2^63-1) otherwise float
| byte / string | string | string
| enum | int | int
| Proto type | PHP type (32 bit) | PHP type (64 bit) |
| ---------------- | ---------------------------------------------- | ------------------------------------------ |
| bool | bool | bool |
| float / double | float | float |
| int32 | int | int |
| int64 / uint32 | int (between -2^31 and 2^31-1) otherwise float | int |
| uint64 | int (between 0 and 2^31-1) otherwise float | int (between 0 and 2^63-1) otherwise float |
| byte / string | string | string |
| enum | int | int |



Expand All @@ -54,21 +52,18 @@ Install

This has only been tested on Linux and Mac. You will need the following libraries:

```
# For Debian based Linux
sudo apt-get install libprotobuf-dev protobuf-compiler
# For Debian based Linux
sudo apt-get install libprotobuf-dev protobuf-compiler

# For Mac
brew install protobuf
```
# For Mac
brew install protobuf

To build:
```
./autogen.sh
./configure
make
sudo make install
```

./autogen.sh
./configure
make
sudo make install


Licence (Simplified BSD License)
Expand Down