protobuf-php/protobuf-plugin
A protoc plugin that generates PHP classes from .proto definitions for the protobuf-php runtime, enabling typed Protocol Buffer message serialization and deserialization in PHP projects.
Architecture fit
protoc plugin — a build-time binary that protoc invokes to emit PHP classes from .proto definitions. Its architectural home is the CI/build toolchain, not the application container.protobuf-php/protobuf (the pure-PHP message runtime). Adopting the plugin without that runtime (or vice versa) is not viable. This matters because the runtime, not the plugin, is what your application actually depends on at request time..proto files between Laravel services and non-PHP services (Go, Java, Python), gRPC clients/servers, or compact event payloads on a queue. It is a poor fit for anything that only talks JSON to itself.Integration feasibility
require-dev Composer dependency, install a pinned protoc in the build image, and invoke protoc --plugin=protoc-gen-php=... --php_out=.... Generated classes are plain PHP and drop into PSR-4 autoloading (e.g. app/Generated/ or a first-party packages/contracts directory).protoc must exist in every environment that regenerates code, and the plugin's expected protoc version must be pinned alongside it.Technical risk
each()-era idioms) or hard-fails on modern runtimes.protoc has shipped a built-in --php_out generator since 3.x, paired with google/protobuf. Choosing this plugin means deliberately selecting the older, unmaintained path.protoc upgrade in the base image can silently change generated output or break the plugin handshake.Key questions
protoc --php_out with google/protobuf?protoc version will we pin, and who owns that pin?ext-grpc and a different runtime story) or only wire-format serialization?optional, Any, and well-known types — areas where old generators are weakest?.proto contracts, and what is the versioning/compatibility policy across services?Stack fit
packages/contracts or a private Composer repo) consumed by the Laravel app. This keeps generated code out of app/ and makes it shareable with other PHP services.config/, the service container, or bootstrap/providers.php.Migration path
google/protobuf + protoc --php_out and skip this plugin entirely. If you inherit a codebase already on protobuf-php/protobuf, this plugin is the consistent choice and migration should be sequenced separately..proto set in a branch, diff the public surface (class names, namespaces, getters/setters, enum handling), and convert call sites behind an internal serialization adapter so application code does not bind to generated classes directly.MessageSerializer interface with a protobuf implementation), then swap the underlying runtime behind it. That makes the generator choice reversible.Compatibility
google/protobuf — installing both runtimes in one app is a known source of class and extension conflicts. Do not allow both.protoc, the plugin, and the runtime as a matched triple in composer.json and the Dockerfile. Record the triple in the repo.Sequencing
protoc --php_out; run round-trip and PHP 8.2 smoke tests; write a one-page recommendation..proto ownership, naming, versioning, and breaking-change policy before any codegen lands.protoc + pinned plugin to the CI image; add a make proto / Artisan wrapper; make CI fail when generated output drifts from committed output.Maintenance
protoc compatibility patch is yours. Budget either a fork with an owner or a planned exit. With zero dependents, there is no community patch flow to free-ride on.Support
.proto authoring, protoc invocation, and wire-format debugging. gRPC adds meaningfully more than plain serialization.Scaling
protoc/plugin/runtime triples you must keep aligned.Failure modes
.proto revisions and deserialize partially, producing null/zero defaults instead of errors. Mitigate with a shared contracts repo and CI drift checks.protobuf-php/protobuf colliding with google/protobuf or ext-protobuf yields confusing class-resolution errors at boot.Timestamp, Duration, Any handling is a common gap in older generators; teams hand-roll conversions and drift.Ramp-up and recommendation
protobuf-php/protobuf in production; greenfield work should use protoc --php_out with google/protobuf. Fund the one-week spike, require a written decision with the pinned version triple, and gate adoption on the PHP 8.x round-trip test passing. Absent that evidence, the expected value of adopting a 2017-era, zero-dependent codegen plugin in a modern Laravel stack is negative.How can I help you explore Laravel packages today?