Page through results
Paging through list results with the SUQO PHP SDK.
Every list endpoint — products->list(), subscriptions->list(), customers->list() — returns the same envelope, and offers two ways to walk it.
The envelope
Suqo\Model\Page<T>:
| Property | Type | Notes |
|---|---|---|
count | int | Total rows across every page, not the size of results. 0 when absent. |
next | ?string | Absolute URL of the next page, or null on the last one. |
previous | ?string | Absolute URL, or null on the first page. |
results | list<T> | The records on this page. |
subscriptions->list() returns a superset — SubscriptionPage — with four account-level counters alongside results: totalSubscriptions, activeSubscriptions, dueSubscriptions and inactiveSubscriptions, each ?int.
Manual paging
Pass page and pageSize yourself:
$page1 = $suqo->products->list(page: 1, pageSize: 50);
$page2 = $suqo->products->list(page: 2, pageSize: 50);pageSize maps to the wire's page_size — the SDK does that translation. Both are omitted from the query string entirely when null, rather than sent as empty values.
autoPaging() — walk every row without page math
Every paginated resource also exposes autoPaging(), which follows next until it is null and yields records one at a time:
foreach ($suqo->products->autoPaging() as $product) {
echo $product->name, PHP_EOL;
}It takes the same parameters as list():
foreach ($suqo->subscriptions->autoPaging(pageSize: 100) as $subscription) {
handle($subscription);
}It returns a PHP Generator, and nothing is accumulated: a page is fetched only once you have exhausted the previous one, so breaking out of the loop early stops the requests. The generator body does not run until first iteration either, which is why errors surface from the foreach rather than from the call.
Page 1 goes through the same absolute-URL GET as every later page, so the retry policy is identical throughout.
The counters are on the page, not the stream
SubscriptionPage's four counters are page-level, so they are not reachable through autoPaging(). Call list() when you want them.
It gives up rather than looping forever
If the server never stops advancing — a next that points back at its own page — iteration would otherwise issue requests forever. It stops after 10 000 pages and raises a base SuqoError naming the cause. Reaching that means the server is not advancing, not that the collection ran out.