kebabtent / pogoprotos-php

Compiled PHP protobufs for pokemon go
MIT License
22 stars 8 forks source link

Enum imports missing #6

Closed DrDelay closed 8 years ago

DrDelay commented 8 years ago

When the Data classes use consts from BadgeType , Gender , ... (I tried GetPlayer) a PHP fatal error arises because they are in another namespace (\POGOProtos\Enums). If I manually add use POGOProtos\Enums\TeamColor; etc. to the top of the affected files this problem is solved, but I guess the class generation should somehow do this automatically.

I would try to look for a way myself too, but I can't get pass this error compiling the protoc-gen-php tool:

$ make
(...)
g++  -g -O2   -o protoc-gen-php protoc-gen-php.o php_generator.o php_options.pb.o strutil.o php_util.o php_enum.o php_field.o php_message.o php_method.o php_read.o php_service.o php_size.o php_tostring.o php_write.o  -lprotobuf -lprotoc
/usr/bin/ld: cannot find -lprotoc
collect2: error: ld returned 1 exit status
Makefile:376: recipe for target 'protoc-gen-php' failed
make[2]: *** [protoc-gen-php] Error 1
make[2]: Leaving directory '/usr/src/protoc-gen-php/src'
Makefile:283: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/src/protoc-gen-php/src'
Makefile:354: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

Since you have it working, any chance you know what I'm doing wrong there?

jaspervdm commented 8 years ago

I was actually looking into the same issue. For some reason it doesnt use the full namespace for TeamColor, but it uses it for other stuff like \POGOProtos\Data\Player\PlayerAvatar. Not sure why, though. I am looking into the code for protoc-gen-php to see if I can figure it out. Worst case scenario we can always write a script that replaces these Enums with their full namespaces. Not very clean, but that should work.

Regarding the compilation: did you do sudo apt-get install libprotobuf-dev protobuf-compiler first?

jaspervdm commented 8 years ago

Oh and if that doesn't work you can run ./install-protobuf.sh