google-api-php-client icon indicating copy to clipboard operation
google-api-php-client copied to clipboard

Custom Namespace issue on google analytics-admin and analytics-data php api.

Open bilal-ahmed-wpb opened this issue 10 months ago • 2 comments

A question raised in my mind. The files in which there is the following comment:

Generated by the protocol buffer compiler. DO NOT EDIT! In google/analytics-admin and google/analytics-data can I add my custom plugin namespace on them and will they work then?

And to make them work as I am using php-scoper to contain them under my own custom namespace in order to avoid plugin conflicts on Wordpress. Any guidance on this please.

bilal-ahmed-wpb avatar Apr 16 '24 12:04 bilal-ahmed-wpb

To give you a context on the comment, the code is fully generated by a generator and, in normal scenarios, if we change that code and merge it to the repository, the generator will generate the code again and overwrite it in the repository (local machines are safe on this overwrite as long as you don't pull the latest, but local machine will be stuck with the old code). Thats why we have that warning.

Hope this information helps.

ajupazhamayil avatar Apr 25 '24 06:04 ajupazhamayil

But as I use the php-scoper or strauss (namespace tool) and then reuse the plugin I get following error:

WARNING MyPlugin\Google\Analytics\Admin\V1alpha\DataStream is not found in descriptor pool. Only generated classes may derive from Message

WARNING MyPlugin\Google\Analytics\Admin\V1alpha\ListDataStreamsRequest is not found in descriptor pool

bilal-ahmed-wpb avatar Apr 25 '24 07:04 bilal-ahmed-wpb

Hello @bilal-ahmed-wpb !

@ajupazhamayil is correct, this code is automatically generated from protobuffs from each API team, that way they can make any necessary changes and the code gets generated for the library :).

So editing the code inside the library is not advised. I recommend you to check the documentation for the php-scoper library.

Closing this as this is a question related to php-scoper and wordpress. If you have any specific questions about the usage of the library, please feel free to comment back!

Hectorhammett avatar Jun 14 '24 19:06 Hectorhammett