protobuf-php / protobuf-plugin Goto Github PK
View Code? Open in Web Editor NEWPHP Code generator plugin from Google's Protocol Buffers
License: MIT License
PHP Code generator plugin from Google's Protocol Buffers
License: MIT License
Error:
No syntax specified for the proto file: php.proto. Please use 'syntax = "proto2";' or
'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)
$ php ./vendor/bin/protobuf --include-descriptors --include="./proto" --generate-imported --out="./src/AppleIworkProtos" ./proto/apple-iwork.proto
Hi!
I'm starting to use your library with a Symfony 3 project. It seems that compatibility has been checked with the MR #6 (Add possibility to install newer version of components).
Do you have planned to create a new version / tag + packagist sync to use it?
Per this documentation: https://developers.google.com/protocol-buffers/docs/proto3#default fields are supposed to return their default value even if the parsed proto doesn't contain that value. Right now, I have to manually check for hasField()
and implement the default value myself.
For example, check out FortType in this proto:
https://github.com/AeonLucid/POGOProtos/blob/master/src/POGOProtos/Map/Fort/FortData.proto
For FortType::GYM (0), my FortData proto doesn't contain any value on type, so getType() will return null, instead it should return FortType::GYM() (the first defined enum value).
Same thing for "owned_by_team": if it's 0, my proto doesn't contain data, and I have to manually check for hasOwnedbyTeam() and then assume 0 if it's missing, instead of just doing getOwnedByTeam()->value().
I shouldn't have to do this work myself judging from the specs.
Same thing applies to proto2: https://developers.google.com/protocol-buffers/docs/proto#optional
Switch to https://github.com/laminas/laminas-code
Problems arise with code generation with PHP 7.4:
--php_out: protoc-gen-php: Plugin output is unparseable: \nWarning: \"continue\" targeting switch is equivalent to \"break\". Did you mean to use \"continue 2\"? in /Users/soulseekah/Development/wp-ipfs/php-libp2p/vendor/zendframework/zend-code/src/Generator/FileGenerator.php on line 135\n\nWarning: \"continue\" targeting switch is equivalent to \"break\". Did you mean to use \"continue 2\"? in /Users/soulseekah/Development/wp-ipfs/php-libp2p/vendor/zendframework/zend-code/src/Generator/FileGenerator.php on line 138\n\nWarning: \"continue\" targeting switch is equivalent to \"break\".
This was fixed in laminas. https://github.com/laminas/laminas-code/blob/4.5.x/src/Generator/FileGenerator.php#L84
I'd like to use this within the latest symfony skeleton but this project only supports up to symfony 3. Can you provide a symfony 4+ version?
Hi,
i have installed all dependencies and packages as described (i can call php and protoc from commandline; installed all scripts via composer, ...)
But when i call
php .\vendor\bin\protobuf.bat --include-descriptors -i . -o ./src/ ./addressbook.proto
i only get the content of the bat-file in the console:
@ECHO OFF
SET BIN_TARGET=%~dp0/../protobuf-php/protobuf-plugin/bin/protobuf
php "%BIN_TARGET%" %*
What iam doing wrong?
I'm trying to generate php code for a particular .proto
file following instructions from the README.
I did the following in an empty directory with addressbook.proto
:
brew install php composer protoc
composer require "protobuf-php/protobuf-plugin
php ./vendor/bin/protobuf --include-descriptors -i . -o ./src/ ./addressbook.proto
I get error saying:
Could not open input file: ./vendor/bin/protobuf
In vendor/
there is only the following folders:
autoload.php composer/ protobuf-php/
What am I missing?
Info:
$ protoc --version
libprotoc 3.2.0
$ composer --version
Composer version 1.3.2 2017-01-27 18:23:41
$ php --version
PHP 7.1.2 (cli) (built: Feb 17 2017 10:51:21) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.