chore: migrate bare curl/utopia-fetch to utopia-php/client#237
Conversation
Replace the three bare-cURL closures in Docker.php and the utopia-php/fetch e2e test client with utopia-php/client, coupling directly to its PSR-18 exception types for retry/timeout control flow. - Docker.php: Curl adapter + RequestFactory; retry loop catches ConnectionException/DnsException (retry) and TimeoutException (v2 EXECUTION_TIMEOUT). Preserves multi-value response headers, v2 JSON_FORCE_OBJECT, and v5's implicit form-urlencoded content type. - tests/e2e/Client.php: utopia-php/client with context-based adapter (Curl outside a coroutine, SwooleCoroutine inside) so direct calls and the concurrent streaming test both work. - composer: php >=8.4, platform 8.4, +utopia-php/client, -utopia-php/fetch. - Build on phpswoole/swoole:6.2.1-php8.4-alpine (openruntimes/base has no 8.4 build); add docker-cli, set WORKDIR. CI test images -> php8.4. - Apply rector php84 idioms required by the platform bump. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…client # Conflicts: # .github/workflows/ci.yml # Dockerfile # app/controllers.php # composer.json # composer.lock # src/Executor/Runner/Docker.php
Greptile SummaryThis PR migrates all bare-cURL and
Confidence Score: 5/5Safe to merge; all three HTTP paths preserve their prior wire behaviour and error-handling contracts, and the e2e test client correctly selects the coroutine-aware adapter at runtime. The migration is mechanically faithful: retry/timeout branching, status-code logic, header normalisation, and content-type fallbacks all match the old cURL code. The exception hierarchy maps cleanly to the prior errNo checks, and no path silently drops or transforms errors in a new way. No files require special attention. Important Files Changed
Reviews (3): Last reviewed commit: "chore: bump utopia-php/client to 0.1.4, ..." | Re-trigger Greptile |
The test client's body encoding fell through to JSON for any non-GET request, so a caller-set content-type of multipart/form-data (used by the binary-body execution scenarios) was sent as JSON under a multipart header. Route multipart -> RequestFactory::multipart (stripping the boundary-less content type so a boundary is emitted) and form-urlencoded -> RequestFactory::form. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The create-runtime request was a closure invoked exactly once in the loop directly below it; inline it (dropping the 10-var capture list, call_user_func, and now-unused ResponseInterface import). executeV2/V5 stay closures since they are version-selected and share the retry loop. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0.1.4 sets CURLOPT_NOBODY for HEAD requests inside the Curl adapter, so executeV5 no longer needs to pass it explicitly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What
Migrates all bare cURL and
utopia-php/fetchcalls ontoutopia-php/client, coupling directly to its PSR-18 exception types for control flow (no translation layer).Net −69 LoC across the source (excluding the generated lockfile).
Changes
src/Executor/Runner/Docker.php— the three bare-cURL closures (sendCreateRuntimeRequest,executeV2,executeV5) now use the Curl adapter +RequestFactory:ConnectionException/DnsException→ retry,TimeoutException→EXECUTION_TIMEOUTfor v2 (else internal error).JSON_FORCE_OBJECT, the implicitapplication/x-www-form-urlencodedcontent type cURL adds for a raw v5 body, andCURLOPT_NOBODYfor HEAD.tests/e2e/Client.php— offutopia-php/fetch, selecting the adapter by context (Curloutside a coroutine,SwooleCoroutineinside) so the 60+ direct calls and the concurrent log-streaming test both work without a bootstrap hook.Build / deps / CI
composer.json:php >=8.4, platform8.4,+utopia-php/client,−utopia-php/fetch(lock regenerated).utopia-php/clientrequires PHP 8.4 — its source uses 8.4-onlynew Foo()->bar()syntax.Dockerfile: build onphpswoole/swoole:6.2.1-php8.4-alpine(openruntimes/basehas no PHP 8.4 build). Addsdocker-cli(the executor shells out to Docker) and setsWORKDIR /usr/local/.ci.yml: unit/e2e Swoole test images5.1.2-php8.3→6.2.1-php8.4.php84idioms (array_any, new-without-parens) applied — required forrefactor:checkto stay green on the 8.4 platform.Verification
composer analyze(phpstan lvl 8) ✅ ·format:check(pint) ✅ ·refactor:check(rector) ✅docker build✅ — image boots clean (PHP 8.4.21,app/http.phpparses, docker CLI present, all three utopia/client adapters autoload)🤖 Generated with Claude Code