I'm sorry the autoloading is of course
```
"psr-0": {
"Famly\\Queue": "Packages/Application/Famly.Queue/Classes"
}
```
On Monday, 28 March 2022 at 12:58:28 UTC+2 Jakob Merrild wrote:
> I'm trying to use the google/protobuf package for php, but am running into
> an issue that I don't understand. When trying to construct an instance of
> the generated class I'm met with the following exception
>
> InvalidArgumentException: Famly\Queue\Model\Proto\ExportRequest is not
> found in descriptor pool. Only generated classes may derive from Message.
>
> I have added the following to `composer.json`
>
> ```
> "require": {
> ...,
> "google/protobuf": "^3.19"
> }.
> "psr-0": {
> "Famly\\Queue": "Packages/Application/Famly/Queue"
> }
> ````
>
> I'm using `protoc` version 3.19.4 and generated the the files with
> protoc --proto_path="famlyqueue/src/main/protobuf"
> --php_out="core/Packages/Application/Famly.Queue/Classes"
> famlyqueue/src/main/protobuf/co/famly/export/ExportRequest.proto
>
> Here's the `proto` file
>
> ```
> syntax = "proto3";
>
> package co.famly.export.proto;
> option php_namespace = "Famly/Queue/Model/Proto";
> option php_metadata_namespace = "Famly/Queue/Model/Proto/Meta";
>
> message ExportRequest {
> // The ID of the entity to export
> string entityId = 1;
> // The type of the entity to export
> ExportEntityType entityType = 2;
> }
>
> enum ExportEntityType {
> BILL_PAYER = 0;
> BILL_PAYER_INVOICES = 1;
> CHILD = 2;
> LOGIN = 3;
> LOGIN_POST_MEDIA = 4;
> SITE = 5;
> SITE_MEDIA = 6;
> }
> ```
>
> And the test where I'm trying to construct the class instance (simply
> roundtrip test)
> ```
> <?php
> namespace Famly\Queue\Model\Proto;
>
> use Neos\Flow\Tests\UnitTestCase;
> use Neos\Flow\Utility\Algorithms;
>
> class ExportRequestTest extends UnitTestCase {
> /**
> * @test
> */
> public function canRoundtripSerialization() {
> $from = new ExportRequest();
> $entityId = Algorithms::generateUUID();
> $from->setEntityId($entityId);
> $from->setEntityType(ExportEntityType::SITE);
>
> $serialized = $from->serializeToString();
>
> $to = new ExportRequest();
> $to->mergeFromString($serialized);
>
> $this->assertEquals($to->getEntityId(), $entityId);
> $this->assertEquals($to->getEntityType(), ExportEntityType::SITE);
> }
> }
> ```
>
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/protobuf/bc141911-eba0-4ebf-8d94-0423f9a31fecn%40googlegroups.com.