(PHP) add experimental support for PHP language.
* codegen for all basic features: WIP (probably implemented all basic feature) * JSON parsing: NO * Simple mutation: NO * Reflection: NO * Buffer verifier: NO (will be add later) * Testing: basic: Yes * Testing: fuzz: Yes * Performance: Not bad * Platform: Supported Linux, OS X, Windows (has 32bit integer limitation) * Engine Unity: No flatc --php monster_test.fbs <?php //include neccessary files. $fbb = new Google\FlatBuffers\FlatBufferBuilder(1); $str = $fbb->createString("monster"); \MyGame\Example\Monster::startMonster($fbb); \MyGame\Example\Monster::addHp($fbb, 80); \MyGame\Example\Monster::addName($fbb, $str); $mon = \MyGame\Example\Monster::endMonster($fbb); $fbb->finish($mon); echo $fbb->sizedByteArray(); PHP 5.4 higher Currently, we do not register this library to packagist as still experimental and versioning problem. If you intended to use flatbuffers with composer. add repostiories section to composer.json like below. "repositories": [{ "type": "vcs", "url": "https://github.com/google/flatbuffers" }], and just put google/flatbuffers. "require": { "google/flatbuffers": "*" } * PHP's integer is platform dependant. we strongly recommend use 64bit machine and don't use uint, ulong types as prevent overflow issue. ref: http://php.net/manual/en/language.types.integer.php * php don't support float type. floating point numbers are always parsed as double precision internally. ref: http://php.net/manual/en/language.types.float.php * ByteBuffer is little bit slow implemnentation due to many chr/ord function calls. Especially encoding objects. This is expected performance as PHP5 has parsing arguments overhead. probably we'll add C-extension. Basically, PHP implementation respects Java and C# implementation. Note: ByteBuffer and FlatBuffersBuilder class are not intended to use other purposes. we may change internal API foreseeable future. PSR-2, PSR-4 standards. Implemented simple assertion class (respect JavaScript testcase implementation) as we prefer small code base. this also keeps CI iteration speed. we'll choose phpunit or something when the test cases grown.
Showing
- CMakeLists.txt 1 addition, 0 deletionsCMakeLists.txt
- composer.json 18 additions, 0 deletionscomposer.json
- include/flatbuffers/idl.h 7 additions, 0 deletionsinclude/flatbuffers/idl.h
- php/ByteBuffer.php 495 additions, 0 deletionsphp/ByteBuffer.php
- php/Constants.php 25 additions, 0 deletionsphp/Constants.php
- php/FlatbufferBuilder.php 918 additions, 0 deletionsphp/FlatbufferBuilder.php
- php/Struct.php 31 additions, 0 deletionsphp/Struct.php
- php/Table.php 129 additions, 0 deletionsphp/Table.php
- src/flatc.cpp 4 additions, 0 deletionssrc/flatc.cpp
- src/idl_gen_php.cpp 980 additions, 0 deletionssrc/idl_gen_php.cpp
- tests/MyGame/Example/Any.php 25 additions, 0 deletionstests/MyGame/Example/Any.php
- tests/MyGame/Example/Color.php 25 additions, 0 deletionstests/MyGame/Example/Color.php
- tests/MyGame/Example/Monster.php 759 additions, 0 deletionstests/MyGame/Example/Monster.php
- tests/MyGame/Example/Stat.php 136 additions, 0 deletionstests/MyGame/Example/Stat.php
- tests/MyGame/Example/Test.php 53 additions, 0 deletionstests/MyGame/Example/Test.php
- tests/MyGame/Example/TestSimpleTableWithEnum.php 99 additions, 0 deletionstests/MyGame/Example/TestSimpleTableWithEnum.php
- tests/MyGame/Example/Vec3.php 96 additions, 0 deletionstests/MyGame/Example/Vec3.php
- tests/generate_code.bat 2 additions, 0 deletionstests/generate_code.bat
- tests/generate_code.sh 1 addition, 1 deletiontests/generate_code.sh
- tests/phpTest.php 609 additions, 0 deletionstests/phpTest.php
Loading
Please register or sign in to comment