Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

gtfs-realtime.proto getting "Proto file missformed" #71

Closed
brians-code opened this issue Jul 3, 2016 · 3 comments
Closed

gtfs-realtime.proto getting "Proto file missformed" #71

brians-code opened this issue Jul 3, 2016 · 3 comments

Comments

@brians-code
Copy link

The proto file I am trying to parse is maintained by Google
https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto
I have the protobuf.so installed and enabled. But when I run

php protoc-php.php gtfs-realtime.proto

I get the message

Proto file missformed

What do you think could be causing the problem?

@hjagodzinski
Copy link
Member

hjagodzinski commented Jul 3, 2016

The php-protobuf comes with a custom made proto parser which supports only a subset of proto syntax - this is why you're getting this informative error. If you would like to you can try out a work in progress branch https://github.com/allegro/php-protobuf/tree/plugin. It uses original protoc compiler. You run it as follows:

php protoc-php-gen.php gtfs-realtime-proto.proto (Run with --help argument to see more options available.)

Run "composer install" before running this commnad in order to have all dependencies installed.

Generated classes are PSR-0 compliant. The option that might interest you is -Dnamespace that allows you to define a namespace to put your classes into:

php protoc-php-gen.php -Dnamespace=Foo\Bar gtfs-realtime-proto.proto

If you try it can you let me know how it worked for you?

@brians-code
Copy link
Author

It worked great, thanks! The only change I had to make was adding quotes to the -D parameter

php protoc-php-gen.php -Dnamespace="Foo\Bar" gtfs-realtime-proto.proto

Otherwise it would concat the namespace and sub-namespace into one word.

You are doing some really interesting work. I like how you structured this as an official plugin to protoc, and are modeling Google's class structure for other generated languages. Who knows when Google will get around to adding a native PHP class generator, and the classes are unlikely to be structured as well as these are. You should reach out to Google and get them to throw some money at you!

@hjagodzinski
Copy link
Member

Great it worked for you! I'm glad you like it, thanks 😉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants