feat: add PHP client for the Apify API (spec v2-2026-07-02T131926Z)#1
Merged
Conversation
Bespoke, idiomatic PHP 8.1+ client (PSR-4 Apify\Client, PSR-12) mirroring the reference JS client: resource clients for actors (+versions, env vars), builds, runs, datasets, key-value stores, request queues, tasks, schedules, webhooks, dispatches, store, users and logs, plus setStatusMessage and actor validateInput. Replaceable transport (Guzzle default + PSR-18 adapter), bearer auth, mandated User-Agent, exponential-backoff retries, 404->null, HMAC storage URL signing, and byte-size-bounded batch request add with uniqueKey validation. Includes unit tests (mock transport), live integration tests, runnable documentation examples with a snippet linter, php-cs-fixer (PSR-12) and PHPStan gates, and CI workflows for integration tests and Packagist publishing.
The committed lock resolved php-cs-fixer's Symfony dependencies to v8.x (requires PHP 8.4.1+) because it was generated on PHP 8.4, but composer.json declares php >=8.1 and CI runs on PHP 8.1, so composer install failed. Pin config.platform.php to 8.1.0 and regenerate the lock (Symfony 6.4.x).
RunClient stored an ApifyClient $root it never read (PHPStan: 'never read, only written'). Drop the constructor parameter and import and the argument at the three call sites; ActorClient/TaskClient keep their own $root, which they use for waitForFinish.
…ccessors The run-nested dataset/key-value-store/request-queue/log accessors created fresh contexts with empty base params, dropping the status/origin filters pinned by ActorClient::lastRun()/TaskClient::lastRun(). DatasetClient listItems/downloadItems/pushItems also bypassed mergedParams. Both are now routed through the inherited base params, matching the apify-client-js reference (sub-resources inherit params via _subResourceOptions/_params). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019etuGDSwcjs4DKuCd4MKKe
…lt, docs, phpstan tests) - Remove dead/misleading BatchAddRequestsOptions::maxParallel (+constant): the synchronous client sends batches sequentially, so the knob had no effect. - ActorClient::defaultBuild now clamps waitForFinish via ctx->clampServerWait, consistent with run/build get() (avoids socket abort under a short timeout). - GetRecordOptions defaults attachment=true (matches JS which always sends it), so a caller-supplied options object no longer silently drops the param. - Remove dead QueryParams::isEmpty(); drop cross-class DatasetClient::extractString helper in favor of ApifyResource::get() + inline is_string at the 3 call sites. - docs/storages.md: request-queue getOrCreate takes only a name (no schema). - phpstan.neon.dist: type-check tests/ too. CHANGELOG notes last-run param propagation. - Tests: new RequestShapeTest::testDefaultBuildClampsWaitToPerRequestTimeout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019etuGDSwcjs4DKuCd4MKKe
Match the Java/Rust/Go sibling clients and the orchestration PR (the spec rolled to 07-02 with a zero diff while this client was generated; pin the same value across all clients for consistency).
…ive log-redirect example; spec v2-2026-07-02T131926Z Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017sJGjCxFP3bpbeF4LsVqK3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the official (experimental, AI-generated and AI-maintained) PHP client for the Apify API, built from scratch and verified against OpenAPI specification
v2-2026-07-01T115402Z. Idiomatic PHP 8.1+ (PSR-4Apify\Client\, PSR-12); the public interface mirrors the JavaScript reference client and is consistent with the Java/Rust/Go siblings.What's included
ApifyClientwith accessors for Actors (+ versions & env vars), builds, runs, datasets, key-value stores, request queues, tasks, schedules, webhooks, webhook dispatches, the Apify Store, users, and logs, plussetStatusMessageand actorvalidateInput.Http\HttpClientInterface(defaultGuzzleHttpClient, plus aPsr18HttpClientadapter for any PSR-18 client).User-Agent, exponential-backoff-with-jitter retries (429/5xx/transport) with a growing-but-capped per-attempt timeout, and404 → nullon single-resource GETs.actor(...)->call/task(...)->call,waitForFinish,defaultBuild,metamorph/reboot/resurrect/charge, run-nested storages, lazystore()->iterate()andrequestQueue(...)->paginateRequests(), dataset download/statistics/public URLs, key-value-store record & key-list public URLs with HMAC-SHA256 signing, and request-queue batch add withuniqueKeyvalidation and payload-size-bounded chunking.Versionconstants; models capture unmodelled API fields for forward compatibility.Tests, docs & CI
404→null, retries, error parsing, batch chunking & retry semantics, signature known-answer vectors), a live integration suite (one GET + one CRUD/complex flow per resource), runnable documentation examples with a snippet linter.docs/reference for every resource (with namespace guidance and a fully runnable program),CHANGELOG.md, README.PHP integration tests(lint + static analysis + unit + integration +Test examples, path-filtered PR-to-master + manual dispatch,APIFY_TOKENguard) and a manualPublish PHP clientworkflow (tag + GitHub release + Packagist notify from repo secrets).Verification
php-cs-fixer— 0 issues (118 files)phpunit— unit 41, examples 42, integration 42 (live,APIFY_TOKENset), 0 failuresScope notes
allowsAgenticUsers/responseFormat,monthlyUsage(date)).webhooks()are read-only, matching the spec (those nested endpoints are GET-only).Generated by Claude Code