Skip to main content

Proto file location

proto/identity/service.proto

Use case

The IdentityService is used for service-to-service identity verification — for example, when another internal microservice or worker needs to register a user without going through the HTTP API. This is separate from the public REST API and is not exposed to external clients.

Proto definition

proto/identity/service.proto
syntax = "proto3";

package identity.v1;

option php_namespace = "App\\Infrastructure\\Identity\\Delivery\\Grpc\\Generated";

// IdentityService - The Binary Highway
// STRICT CONTRACT: Changes here require versioning.
service IdentityService {
  rpc RegisterUser (RegisterUserRequest) returns (RegisterUserResponse);
}

message RegisterUserRequest {
  string email = 1;
  string password = 2;
  string role = 3;
  string tenant_id = 4;
  string name = 5;
}

message RegisterUserResponse {
  string user_id = 1;
  // Status: "registered", "pending_verification", etc.
  string status = 2;
}

Service definition

RegisterUser

Registers a new user in the identity system. Request: RegisterUserRequest
FieldTypeField numberDescription
emailstring1User email address
passwordstring2Plain-text password (transmitted over encrypted channel)
rolestring3User role (e.g. owner, staff)
tenant_idstring4UUID of the tenant to associate the user with
namestring5Display name
Response: RegisterUserResponse
FieldTypeField numberDescription
user_idstring1UUID of the newly created user
statusstring2Registration status: registered, pending_verification, etc.

PHP generated namespace

Generated PHP classes are placed in:
App\Infrastructure\Identity\Delivery\Grpc\Generated
The php_namespace option in the proto file maps to this namespace.

Versioning

The proto file uses package identity.v1. Any breaking changes to message fields or the service definition require a new package version (e.g. identity.v2). Do not remove or renumber existing fields — mark them as reserved instead.

Generating PHP stubs

After modifying the proto file, regenerate the PHP stubs:
protoc --php_out=app/Infrastructure/Identity/Delivery/Grpc/Generated \
       --grpc_out=app/Infrastructure/Identity/Delivery/Grpc/Generated \
       --plugin=protoc-gen-grpc=$(which grpc_php_plugin) \
       proto/identity/service.proto

Build docs developers (and LLMs) love