Giter Site home page Giter Site logo

Comments (9)

hjagodzinski avatar hjagodzinski commented on August 16, 2024

There is no mention about this class because it's not needed πŸ˜‰ What's the exact issue you're dealing with?

from php-protobuf.

swapniel99 avatar swapniel99 commented on August 16, 2024

How to deserialize such a message, can you please give an example?

from php-protobuf.

hjagodzinski avatar hjagodzinski commented on August 16, 2024

Take a look at Usage.

from php-protobuf.

swapniel99 avatar swapniel99 commented on August 16, 2024

Your hints and clues won't work because I am not a PHP programmer. Usage doesn't show the nested case I am asking about.

Please tell me how to create such a PHP object and serialize it. How to deserialize it. How to include multiple php files generated.

from php-protobuf.

hjagodzinski avatar hjagodzinski commented on August 16, 2024

The only difference the nested case implies is different class name, nothing more. Please find an example for your case but it doesn't show much more than the Usage section.

require_once 'Foo_Sub.php';

$fooSub = new \Foo_Sub();
$fooSub->setId(1);
$fooSub->setAgeSec(2);
$packed = $fooSub->serializeToString();

$unpackedSubFoo = new \Foo_Sub();
$unpackedSubFoo->parseFromString($packed);
$unpackedSubFoo->dump();

from php-protobuf.

swapniel99 avatar swapniel99 commented on August 16, 2024

This I was able to do before. But don't we need to add $fooSub to $foo somehow? Like shouldn't there be addSub function in Foo?
So that we get a single packed string. When I receive a packed string how do i differentiate?

from php-protobuf.

hjagodzinski avatar hjagodzinski commented on August 16, 2024

You don't have a field of type Sub in Foo message..

from php-protobuf.

swapniel99 avatar swapniel99 commented on August 16, 2024

Yes.. But shouldn't there be? The example you gave simply deals with Foo_Sub.
Not the entire Foo. How to do that?

from php-protobuf.

hjagodzinski avatar hjagodzinski commented on August 16, 2024

No, you don't need to define a field of nested type, it's up to you but basically you define nested messages to use them in a parent message.

from php-protobuf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.