Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.law4devs.eu/llms.txt

Use this file to discover all available pages before exploring further.

Overview

All list() methods return a Page<T> object. Every page includes the data array, metadata about the total result set, and links to the next/previous page.

The Page Object

$page = $client->articles->list('gdpr');

// Data
$articles = $page->data;          // ArticleSummary[]
$count    = $page->count();       // items on this page

// Metadata
$total   = $page->meta->total;    // total results across all pages
$current = $page->meta->page;     // current page number
$perPage = $page->meta->perPage;  // items per page
$pages   = $page->meta->pages;    // total number of pages

// Links
$nextUrl = $page->links->next;    // URL of next page (null if last)
$prevUrl = $page->links->prev;    // URL of previous page (null if first)

Manual Pagination

Control pagination yourself with $page and $perPage:
$pageNum = 1;

do {
    $page = $client->articles->list('gdpr', page: $pageNum, perPage: 50);

    foreach ($page->data as $article) {
        echo $article->title . "\n";
    }

    $pageNum++;
} while ($page->links->next !== null);

Auto-Pagination with iter()

Every resource exposes an iter() method that automatically fetches all pages and yields individual items:
// Yields ArticleSummary one by one — no manual paging needed
foreach ($client->articles->iter('gdpr') as $article) {
    echo $article->articleNumber . ' ' . $article->title . "\n";
}
Internally, iter() calls list() repeatedly, following links->next until there are no more pages.
Use iter() whenever you need all items. It handles pagination transparently and uses PHP generators, so it doesn’t load the full result set into memory at once.

Collecting into an Array

If you need a full array, use iterator_to_array():
$articles = iterator_to_array($client->articles->iter('cra'));
echo count($articles) . " total articles\n";

Pagination Parameters

ParameterTypeDefaultDescription
$pageint|null1Page number (1-indexed)
$perPageint|null20Items per page (max 100)