# PHP UDB SDK ACME Billing Example
Standalone PHP project using an arbitrary `acme.billing.v1` proto package.
This example does not require a UDB source checkout. It uses:
- the PHP SDK package from GitHub
- `buf` for generated project models
- UDB CLI from a GitHub Release, or the UDB broker/CLI image through local Docker Compose
## Project Files
| `proto/` | The ACME Billing proto used by both UDB and Buf |
| `gen/` | Generated PHP protobuf models |
| `db_ops/` | Generated by UDB CLI; ignored by git |
| `docker-compose.yml` | Local Postgres, Redis, Qdrant, MinIO, and UDB broker |
| `scripts/` | Project commands that call UDB as an external CLI/image |
| `acme_billing.php` | PHP SDK smoke client using generated `Product` |
## Generate
Use Docker for the UDB CLI:
```powershell
.\scripts\generate.ps1 -Runner docker
```
Or use a GitHub Release CLI binary:
```powershell
$env:UDB_RUNNER = "release"
.\scripts\generate.ps1
```
This runs `buf generate`, installs Composer dependencies, then asks UDB to
generate `db_ops/` from `proto/`.
Before the first public UDB release exists, the default
`releases/latest/download/...` URL will 404. For local pre-release testing,
point the scripts at a binary you already built or downloaded:
```powershell
cargo build --release --bin udb-proto-parser
$env:UDB_CLI = "E:\Projects\udb\target\release\udb-proto-parser.exe"
.\scripts\generate.ps1 -Runner auto
```
For Docker-based pre-release testing, expose a real URL to the Linux binary with
`UDB_CLI_URL`. A Windows path cannot be executed inside the Linux Compose
container.
## Start Broker
```powershell
.\scripts\serve.ps1
.\scripts\bootstrap.ps1 -Runner docker
```
The compose stack provides Postgres, Redis, Qdrant, MinIO, and the UDB broker.
## Run Client
PHP needs the `grpc` extension enabled for live RPC calls.
```powershell
$env:UDB_TARGET = "127.0.0.1:50051"
php acme_billing.php
```
## Checks
```powershell
buf lint
composer validate --no-check-publish
php -l acme_billing.php
```