Skip to content

Relocate well known packages into alternative php namespaces to resolve conflict with google/protobuf - #37

Open
kafkiansky wants to merge 5 commits into
0.5.xfrom
namespace-mapping
Open

Relocate well known packages into alternative php namespaces to resolve conflict with google/protobuf#37
kafkiansky wants to merge 5 commits into
0.5.xfrom
namespace-mapping

Conversation

@kafkiansky

@kafkiansky kafkiansky commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Thesis is an alternative runtime, so its generated code must be able to live in the same project as the code generated by google/protobuf. That was impossible as long as both generate Google\Protobuf\Any: the class names collide, which is why thesis/protobuf-known-types had to declare conflict: google/protobuf, and that conflict, in turn, made it impossible to use packages tied to google/protobuf (open-telemetry/*, for instance).

This PR teaches the plugin to relocate well known packages into namespaces of its own.

The relocation table is map.json in the repository root. It is bundled into the phar (box.json) and shipped with the composer package, so it applies no matter how the plugin is installed.

{
    "rules": [
        {"from": "google.protobuf.*", "to": "thesis.google.protobuf.*"},
        {"from": "google.rpc.Status", "to": "thesis.google.rpc.Status"}
    ]
}

Rules are written in terms of protobuf names, not PHP ones — the PHP namespace is derived from the rewritten name exactly the same way it is derived from a package.

@kafkiansky kafkiansky self-assigned this Aug 9, 2026
@kafkiansky kafkiansky added the enhancement New feature or request label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant