feat: v2.0.0 — first-class PHP SDK rewrite#1
Conversation
Ground-up PHP SDK for OilPriceAPI: - Zero runtime dependencies (ext-curl + ext-json only) — works on shared hosting and WordPress; PHP >= 8.1, strict types, PSR-4 - Client: latest(by_code), pastDay/Week/Month/Year, keyless demoPrices(), raw() escape hatch for any endpoint - OILPRICEAPI_KEY env fallback; helpful AuthenticationException with signup URL when keyed endpoints are called without a key - Retries with exponential backoff + jitter on 429/5xx, honors Retry-After; 10s default timeout, configurable - Typed exceptions: ApiException, AuthenticationException, RateLimitException (retryAfter + limit + upgrade URL), TransportException; surfaces the production nested error envelope - Immutable Price DTO (code, price, currency, updatedAt as DateTimeImmutable, change24h, name/unit/type/formatted) w/ toArray() - HttpTransport interface; offline PHPUnit suite (16 tests, 80 assertions) verified on PHP 8.1 (Docker) and 8.5 (local) - CI: PHP 8.1/8.2/8.3 matrix, composer validate --strict, shell-guarded optional live smoke test (no step-level secrets context) - README: quick start, plain-PHP no-composer cURL example, demo mode, gas/LNG/carbon/fuels section, WordPress note, error/retry docs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Ground-up v2.0.0 PHP SDK for OilPriceAPI, triggered by a real customer asking for PHP example code (2026-07-02) and the ICP analysis showing our #1 buyers are embedders with an existing paying PHP segment (guzzlehttp UA: 50k reqs / 12 payers / 30d; wordpress: 60k / 20).
About v1
There was no v1: this repo was created 2025-12-16, archived, and unarchived with zero commits — no code, no README, nothing to migrate or delete. Because GitHub cannot host a PR against a commit-less repo,
mainwas seeded with a single stub-README init commit (5402428), and this PR contains the entire SDK on top of it.What's in the box
ext-curl+ext-jsononly (no Guzzle), so it runs on shared hosting and inside WordPress. PHP >= 8.1,strict_typeseverywhere, PSR-4 (OilPriceAPI\).Client—latest(?$byCode),pastDay/pastWeek/pastMonth/pastYear(?$byCode), keylessdemoPrices(), and araw()->get($path, $params)escape hatch so ANY endpoint (e.g./v1/futures/ice-brent/curve) is reachable without an SDK release.Authorization: Token <key>(verified against docs.oilpriceapi.com and the Go SDK),OILPRICEAPI_KEYenv fallback. Keyless client throws a helpfulAuthenticationExceptionpointing at the signup URL anddemoPrices().Retry-After(numeric and HTTP-date), 10s default timeout, all configurable.ApiExceptionbase,AuthenticationException(signup hint),RateLimitException(retryAfter, plan limit, upgrade URL),TransportException. Extracts the production nested{"error":{"message":...}}envelope (verified against the live API).PriceDTO — immutable;code,price,currency,updatedAt(DateTimeImmutable),change24h, plusname/unit/type/formatted;toArray().HttpTransportmock. Green on PHP 8.1 (Docker) and 8.5 (local).composer validate --strict, PHPUnit. The optional live smoke step is guarded in shell ([ -z "$OILPRICEAPI_TEST_KEY" ]), never with step-levelif: ${{ secrets.* }}(the bug that invalidated workflows in sibling repos); it skips gracefully since that secret is empty org-wide.raw(), DIESEL_USD; maritime compliance / fleet & logistics / LNG analytics / CBAM), WordPress note linking the no-code plugin, error-handling and retry docs.Verification
composer validate --strictpasses.examples/quickstart.phpin demo mode returns real prices from/v1/demo/prices.OILPRICEAPI_KEYon this machine is stale (401 from production). The auth header format matches the docs and Go SDK exactly, but a happy-path live call with a valid key is a follow-up.Post-merge (Karl)
v2.0.0and submitoilpriceapi/oilpriceapito Packagist (publication pending — manual step).OILPRICEAPI_TEST_KEYorg secret to activate the CI live smoke test.🤖 Generated with Claude Code