美文网首页
PHP-Protobuf的问题记录

PHP-Protobuf的问题记录

作者: 一条湫刀鱼 | 来源:发表于2017-04-14 11:20 被阅读732次
    PHP Fatal error:  Generated message class \0rotobufBenchmarks\-essage\Person hasn't been defined in /pb-performance-comparison/src/GPBMetadata/Person.php on line 29
    PHP Stack trace:
    PHP   1. {main}() /pb-performance-comparison/vendor/athletic/athletic/bin/athletic:0
    PHP   2. Athletic\Athletic->run() /pb-performance-comparison/vendor/athletic/athletic/bin/athletic:19
    PHP   3. Athletic\Athletic->benchmark() /pb-performance-comparison/vendor/athletic/athletic/src/Athletic/Athletic.php:38
    PHP   4. Athletic\Runners\SuiteRunner->runSuite() /pb-performance-comparison/vendor/athletic/athletic/src/Athletic/Athletic.php:61
    PHP   5. Athletic\Runners\SuiteRunner->runClass() /pb-performance-comparison/vendor/athletic/athletic/src/Athletic/Runners/SuiteRunner.php:59
    PHP   6. Athletic\Runners\ClassRunner->run() /pb-performance-comparison/vendor/athletic/athletic/src/Athletic/Runners/SuiteRunner.php:74
    PHP   7. Athletic\AthleticEvent->run() /pb-performance-comparison/vendor/athletic/athletic/src/Athletic/Runners/ClassRunner.php:58
    PHP   8. ProtobufBenchmarks\EncodeEvent->classSetUp() /pb-performance-comparison/vendor/athletic/athletic/src/Athletic/AthleticEvent.php:77
    PHP   9. ProtobufBenchmarks\Person->GenerateProto() /pb-performance-comparison/src/ProtobufBenchmarks/EncodeEvent.php:38
    PHP  10. ProtobufBenchmarks\Message\Person->__construct() /pb-performance-comparison/src/ProtobufBenchmarks/Person.php:28
    PHP  11. GPBMetadata\Person::initOnce() /pb-performance-comparison/src/ProtobufBenchmarks/Message/Person.php:34
    PHP  12. Google\Protobuf\Internal\DescriptorPool->internalAddGeneratedFile() /pb-performance-comparison/src/GPBMetadata/Person.php:29
    
    syntax = "proto3";
    
    package ProtobufBenchmarks.Message;
    
    message Person {
      string name = 1;
      int32 id = 2;
      string email = 3;
    
      enum PhoneType {
        MOBILE = 0;
        HOME = 1;
        WORK = 2;
      }
    
      message PhoneNumber {
        string number = 1;
        PhoneType type = 2;
      }
    
      repeated PhoneNumber phone = 4;
    }
    

    解决方法:
    https://developers.google.com/protocol-buffers/docs/reference/php-generated#invocation

    message TestMessage {
      optional int32 a = 1;
      message NestedMessage {...}
    }
    // The compiler will generate the following classes:
    class TestMessage {
      public a;
    }
    
    // PHP doesn’t support nested classes.
    class TestMessage_NestedMessage {...}
    

    不要在你的*.proto文件中编写 message的嵌套使用代码。

    相关文章

      网友评论

          本文标题:PHP-Protobuf的问题记录

          本文链接:https://www.haomeiwen.com/subject/orjwattx.html