sdk-php
Skill8.2k starsChanged 56 days agoApache-2.0View on GitHub
How to build and extend the PHP SDK in sdks/php. Read this before changing the client, the generated DTOs, the Amp worker (dispatch, watch, realtime), folder sync, or before reaching for a dependency.
Trending
More talk lately.thin dataabout the whole repository
Who's talking about GetStream/Agents
- sudosubin/agents.nix“agent-skills.github.getstream.agents: 0.6.404 → 0.6.405”GitHub · Nov 30, 2026
- sudosubin/agents.nix“agent-skills.github.getstream.agents: 0.6.403 → 0.6.404”GitHub · Nov 30, 2026
- sudosubin/agents.nix“agent-skills.github.getstream.agents: 0.6.402 → 0.6.403”GitHub · Nov 29, 2026
- sudosubin/agents.nix“agent-skills.github.getstream.agents: 0.6.399 → 0.6.402”GitHub · Nov 27, 2026
- sudosubin/agents.nix“agent-skills.github.getstream.agents: 0.7.1 → 0.6.399”GitHub · Nov 27, 2026
The biggest 5 of 8 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 8
Talked about on GitHub (8 times).
On GitHub · 8
- Nov 30, 2026agent-skills.github.getstream.agents: 0.6.404 → 0.6.405 — sudosubin/agents.nix0 reactions
- Nov 30, 2026agent-skills.github.getstream.agents: 0.6.403 → 0.6.404 — sudosubin/agents.nix0 reactions
- Nov 29, 2026agent-skills.github.getstream.agents: 0.6.402 → 0.6.403 — sudosubin/agents.nix0 reactions
- Nov 27, 2026agent-skills.github.getstream.agents: 0.6.399 → 0.6.402 — sudosubin/agents.nix0 reactions
- Nov 27, 2026agent-skills.github.getstream.agents: 0.7.1 → 0.6.399 — sudosubin/agents.nix0 reactions
3 more on GitHub
- Nov 25, 2026fix: retain 7 reviewed references that left discovery (Nov 25) — tekvisions/voice-index0 reactions
- Nov 24, 2026agent-skills.github.getstream.agents: 0.7.0 → 0.7.1 — sudosubin/agents.nix0 reactions
- Nov 17, 2026agent-skills.github.getstream.agents: init at 0.7.0 — sudosubin/agents.nix0 reactions
In this repository55 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/python.mdcCursor rule
- pr-reviewSkill
- typesafe-aiSkill
- vgpuSkill
- accelerate-sales-engineerSkill
- add-connectorSkill
- check_pricesSkill
- cliSkill
- commitSkill
- connectorsSkill
- dashboardSkill
- decision_modelSkill
- deploySkill
- docsSkill
- generative-uiSkill
- good_morningSkill
- goSkill
- go-testingSkill
- integrate_new_modelsSkill
- llm-interfaceSkill
- loop_performance_benchSkill
- migrate-to-accelerateSkill
- new_modelsSkill
- paginationSkill
- parallel-agentsSkill
- performance_benchmarkSkill
- phonecheckSkill
- pricingSkill
- prospect-competitor-researchSkill
- provider_auditSkill
- prSkill
- querySkill
- refresh_model_statsSkill
- router-detectionSkill
- router-interfaceSkill
- router-llmSkill
- router-searchSkill
- router-stsSkill
- router-sttSkill
- router-ttsSkill
- scheduled-tasksSkill
- sdk-dartSkill
- sdk-dotnetSkill
- sdk-goSkill
- sdk-jsSkill
- sdk-kotlinSkill
- sdk-rubySkill
- sdk-rustSkill
- sdkSkill
- sdk-swiftSkill
- securitySkill
- sttSkill
- telnyxSkill
- ttsSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 71
Null means omit: Every optional DTO field is nullable and toArray() drops nulls.
- Very specific: line 153
Write the git blob ids of acceleration/api/openapi.yaml and .claude/skills/sdk/SKILL.md to sdks/php/.sdk_update_log, as the sdk skill's SDK …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PHP SDK conventions
The per-language half of sdk, for the server side only. It records the
decisions sdks/php already follows, so a change lands consistently
rather than re-litigating them.
One Composer package, getstream/vision-agents, namespace GetStream\VisionAgents. PHP ^8.4,
tested on 8.4 and 8.5. Strict types everywhere, final readonly classes, backed enums.
Layout
src/
Client.php Backend.php Http.php Json.php core: PSR-18 transport, auth, tolerant JSON
Agent.php Session.php Sessions.php Responses.php Items.php AgentResponse.php AgentHandle.php
Folder.php Folder/ Skill.php Harness.php Pipeline.php Tools.php Knowledge.php
Edge.php Edge/StreamTransport.php Call.php the Stream call, through getstream/getstream-php
Router.php Router/ search, recordings, realtime entry points
Inbound/ InboundCall, InboundMessage
Worker/ Amp only: Socket, Dispatch, Watch, Realtime
Exception/
Generated/ bin/generate.php output, never edited
bin/generate.php
tests/Unit tests/Live tests/Support tests/server/router.phpWhy these choices
- Name.
getstream/vision-agentssits besidegetstream/getstream-phpon Packagist. Packagist needscomposer.jsonat a repository root, so publishing is a splitsh/lite subtree split ofsdks/phpinto its own repo from CI. Do not publish from the monorepo. - PHP 8.4. 8.3 left active support at the end of 2025; 8.4 gives
new Foo()->bar(), property hooks if ever wanted, and is what the official images ship. Readonly classes and typed class constants need 8.3+ anyway. - PSR-18/17 plus
php-http/discovery. A PHP app already owns an HTTP client (Guzzle, Symfony). Exposing Guzzle would force a version on them. Discovery finds whatever is installed; the constructor takes any client and factories. Discovery's Composer plugin is disabled (allow-plugins: false): it must never install packages behind a user's back. - Generation: a small in-repo generator, DTOs only. openapi-generator's
php-nextgenis still beta and emits a Guzzle-bound client per operation; Jane is Symfony-shaped; Stainless is a hosted product. The spec is the router's own and uses a narrow subset of OpenAPI, sobin/generate.php(about 300 lines, Symfony Yaml) writes onefinal readonlyclass per object schema and one backed enum per enum schema, deterministic and diffable, with a--checkmode for CI. Operations are not generated:Clienthas one method per HTTP verb, as in JS, and the hand-written resources hydrate the DTOs. - The core/worker split. A PHP web request is short-lived; a websocket is not. So the core
(everything outside
Worker/) is synchronous PSR-18 and has no event-loop dependency: it runs under FPM, Laravel, Symfony. Anything holding a socket (Session::watch,Dispatch,Router::*->realtime()) lives inWorker/and needsamphp/websocket-client^2 (Revolt, fibers), listed undersuggest, neverrequire. Amp over ReactPHP because it is fiber-based: handlers are plain blocking-looking code, and the sameClientworks inside and outside the loop. - Amp's PSR-18 adapter is preferred when installed (
Http::client()), so an HTTP request made from a dispatch handler suspends its fiber instead of stalling every other call the worker holds. It is built withDnsSocketConnector(Amp's default connector retries a refused connection with backoff: a dead router took 18 s to fail) and a 120 s transfer timeout (opening a session returns only once the agent is in the call). - Stream's PHP SDK for calls.
Edgeusesgetstream/getstream-php^12.1 (VideoClient), sent throughEdge\StreamTransport, an adapter over our PSR-18 client, so it too suspends in a worker, and tests point it at the local server. It needs a secret of 32+ bytes (firebase/php-jwt refuses shorter). Built lazily: an agent that only chats needs no Stream credentials.
Rules
- Null means omit. Every optional DTO field is nullable and
toArray()drops nulls. Never copy a schema default into PHP: the router or the stored config decides. - Tolerant reading.
Json::*readers never throw on a missing or mistyped field. Enums areEnum|string: an unknown value is kept as the raw string, never refused. Date-times areDateTimeImmutable, fractional seconds cut to 6 digits (Go sends 9). - Errors.
RouterExceptioncarriesstatus(0 when nothing arrived),operation(METHOD /path),said(the envelope'serror.message),body,retryAfter, andtype,errorCode(notcode: that isException's own integer),docUrlandrequestId(X-Request-Id), all?string.RouterException::answeredbuilds every one from a response, HTTP and socket handshake alike; a body that is not the envelope (a proxy's HTML, empty, an older router's{"error": "..."}string) issaidas it came, or the status text, with null type, code and doc URL. Local misuse isConfigurationException, raised before a request. Socketerrorframes areRealtimeException; a failed recording job isRecordingFailedException. - Auth is
Backend::headers(), minted per request. Server sockets send the same headers on the handshake, never credentials in the query string. - No reconnect. A dropped socket ends the iterator or
run(); the owner decides. A frame that is not a JSON object, or of an unknown type, is skipped, never fatal. - Tool results repeat
request_idandturn_idfrom thetool_callwhen present, or a durable command's result is refused. Tools run in their own fiber; atool_canceldrops the answer (a PHP callable cannot be interrupted). - Dispatch sends
activeandhandleson the handshake, answers every call and message withdoneand itswork_id(anerrorwhen it failed or had no handler), answers a message with asession_idthroughanswer, reportsload {active_agents, latency_ms}after aping/ponground trip, drains running handlers on exit, and traps SIGINT/SIGTERM only when pcntl is loaded (the official image has none).getOrCreateAgentholds a per-channelLocalKeyedMutexso two messages cannot start two agents. - Folder sync ports Go exactly.
Folder::fingerprintis Go'sfingerprint; with only a subagent and cost labels set,Agent::syncproduces Go's hash (fmt.Sprintof a map ismap[k:v ...], keys sorted). The fixture hash02a7b2c8428f31e3a2b93ca2f5a6ec70is pinned inFolderTest; if it moves, the port is wrong, not the pin..agent_syncis{"hash","synced_at":"...+00:00"}; a matching stamp reads the stored config instead of syncing. Unknownagent.yamlkeys are refused. connectors:is read like Go's (Folder/Connector.php): a string is a session binding, an object{name, connector, tools, connection, required}; absent sends nothing,[]clears. A fixedconnectionis resolved throughGET /v1/agents/connections(every page) at sync time. A non-emptypluginsis refused (Declaration::refuseReplaced); an empty one loads.- Rewind takes a response
id, never aturn_id, and answers 204. Fork takesresponseIdinForkSessionRequest. A persisted conversation refuses rewind with 400. responses->create()returns while the response isrunning. It does not wait; the live tests pollresponses->list().- Realtime
startframes nest options under the modality key ({"type":"start", "config_id":..., "stt":{...}}). The router reads only its own modality's block. - Comments state constraints only. Docblocks are short.
Testing
- No mocks. Unit tests run against
php -Sexecutingtests/server/router.php, which answers from a JSON script and records every request; assertions are on what was sent. Socket tests run a realamphp/websocket-serveron the same Revolt loop (tests/Support/LocalSocketServer), playing the router's side. - Live tests (
tests/Live) are skipped unlessVISION_AGENTS_URLis set;VISION_AGENTS_CUSTOMER_IDdefaults toexamples. Never start or restart the router for them. - PHPStan at
level: maxwithphpstan-strict-rules, oversrc,testsandbin(tests/serverexcluded: it is a script forphp -S).
Docker
The host has no PHP. Everything runs in the official images; nothing is installed on the host.
docker run --rm -v "$PWD":/repo -v "$PWD/sdks/php/build/composer-cache":/tmp/composer-cache \
-e COMPOSER_CACHE_DIR=/tmp/composer-cache -w /repo/sdks/php composer:2 install
docker run --rm -v "$PWD":/repo -w /repo/sdks/php php:8.4-cli vendor/bin/phpunit --testsuite unit
docker run --rm -v "$PWD":/repo -w /repo/sdks/php php:8.4-cli vendor/bin/phpstan analyse --memory-limit=1G
docker run --rm -v "$PWD":/repo -w /repo/sdks/php php:8.4-cli php bin/generate.php ../../acceleration/api/openapi.yaml --check
docker run --rm -v "$PWD":/repo -w /repo/sdks/php -e VISION_AGENTS_URL=http://host.docker.internal:8091 \
php:8.4-cli vendor/bin/phpunit --testsuite liveMount the repo root, not sdks/php: the generator reads ../../acceleration/api/openapi.yaml.
composer:2 runs Composer (it has zip); php:8.4-cli and php:8.5-cli run the tests. The
Composer cache lives in build/, which is gitignored. A custom Dockerfile was dropped when the
Docker VM disk was full; do not prune shared images or volumes to make room.
After the spec changes
php bin/generate.php ../../acceleration/api/openapi.yamland review the diff.- Hand-written resources only change for a new behaviour, not a new field.
- Unit tests, PHPStan, then the live suite once.
- Write the git blob ids of
acceleration/api/openapi.yamland.claude/skills/sdk/SKILL.mdtosdks/php/.sdk_update_log, as the sdk skill's SDK updates section says, so the next update can diff what changed since.
Review checklist
- A new optional field defaulted in PHP instead of left null.
- An enum read with
from()instead of tolerating unknown values. - A socket, event loop or Amp class referenced outside
Worker/(except the guardedSession::watchandRouterentry points, which only construct worker objects). - A blocking
sleep/usleepin code a worker calls (usePause::for). - A mock, or an assertion on which method ran instead of what went over the wire.
agent.yamlhandling that silently ignores a key.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

