/** @return \Generator<int, MemberResource, mixed, void> */
public function iterate(
?int $limit = null,
?int $offset = null,
?string $search = null,
?string $roleId = null,
int|float|null $timeout = null,
): \GeneratorYields members individually and fetches the next page only once the current one is drained. Use it when you want to stop at the first match instead of loading the whole set.
It returns a Generator, so put the call straight into a foreach loop. No request goes out until the first iteration, and breaking out of the loop leaves the remaining pages unfetched.
Example
use Envless\Envless;
$envless = new Envless();
foreach ($envless->members->iterate() as $member) {
if (($member['user']['email'] ?? '') === 'dev@example.com') {
echo $member['id'], ' ', $member['role']['name'] ?? 'no role', PHP_EOL;
break;
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$limit | int | No | Page size fetched behind the scenes, clamped to 100. |
$offset | int | No | Row to start streaming from. |
$search | string | No | Case insensitive substring match on the member name, email or role name. |
$roleId | string | No | Only members holding this role, by the role id from $envless->roles->list(). |
$timeout | int|float | No | Seconds each attempt of this call may take, the response body included, before it throws Envless\Exception\NetworkException with isTimeout() true. Overrides the client's timeout for this call, and 0 turns the limit off. |
Returns
A Generator that yields MemberResource values until the pages run out.
Reads the members collection. list returns one page as an Envless\Result\Page with items and pagination, listAll collects every page into an array, and iterate returns a Generator that yields one item at a time, fetching the next page only when the loop gets there.
Worth knowing
- The offset advances by the number of rows actually received, so members added mid walk can shift the window.
- Most workspaces fit inside one page of 100, in which case this makes a single request and ends.
Required scopes
members:read
Underlying endpoint
GET /members
Request and response schema, every error code, and a live playground.
In TypeScript
envless.members.iterate()
The same method in @goenvless/sdk, with the same request, retries and errors.