Reputation: 49
I've currently trying to parse a .proto file into php. I've tried using DrSlump's Protobuf Parser but either my knowledge is too small or my Godaddy Shared Hosting is missing something. I've tried everything with my knowledge with no success to get what I want.
So my Question, is there any step by step tutorial on how to get this working?
I've got protoc installed with SSH and also installed
pear channel-discover pear.pollinimini.net
pear install drslump/Protobuf-beta
Current issue:
root@v0071:~/Root/var/www/xxx.com/web/test# protoc-gen-php
Protobuf-PHP 0.9.4 by Ivan -DrSlump- Montes
Error: You must provide at least 1 argument.
Type "/usr/bin/protoc-gen-php --help" to get help.
root@v0071:~/Root/var/www/xxx.com/web/test# php protoc-gen-php.php LandData.proto
Protobuf-PHP @package_version@ by Ivan -DrSlump- Montes
/var/www/clients/client1/web10/web/test/LandData.proto:
File does not reside within any path specified using --proto_path (or -I).
You must specify a --proto_path which encompasses this file.
Note that the proto_path must be an exact prefix of
the .proto file names --protoc is too dumb to figure out when two
paths (e.g. absolute and relative) are equivalent
(it's harder than you think).
ERROR: protoc exited with an error (1) when executed with:
protoc \--plugin=protoc-gen-php='/var/www/clients/client1/
web10/web/test/protoc-gen-php.php' \
--proto_path='/var/www/clients/client1/web10/web/test/
library/DrSlump/Protobuf/Compiler/protos' \--php_out=':./' \
'/var/www/clients/client1/web10/web/test/LandData.proto'
Upvotes: 2
Views: 1476
Reputation: 111
Even though the question is old, I thought of answering and maybe someone will find it helpful.
First i would recommend you to use the official library from the Protobuf
github repository.
So what I understand is that you are trying to generate PHP clases from a proto file. To do that you must first install protocol buffer compiler(protoc). At the end of the link you can find the releases.
The easiest way to install protoc
is by using the binaries and afterwards, you can compile the file once you are in the "/protobufBinaries/bin"
and you will find protoc
there.
Now that you have protoc, you can run: ./protoc --php_out=/var/www/html/generated_files /var/www/html/proto/example.proto --proto_path=/var/www/html/proto
NOTE: Do not forget to specify the --proto_path otherwise it will give an error. You need to specify the same path but dont have to include the file. You must specify a --proto_path which encompasses this file.
In my case, the classes were generated in /var/www/html/generated_files
.
Good luck
Upvotes: 1