Projects

$envless->projects->iterate()

Stream projects one row at a time

php
/** @return \Generator<int, ProjectResource, mixed, void> */
public function iterate(
    ?int $limit = null,
    ?int $offset = null,
    ?string $search = null,
    ?string $order = null,
    ?string $product = null,
    int|float|null $timeout = null,
): \Generator

Yields projects individually, fetching the next page only once the current one is drained. This keeps memory flat over large workspaces and lets you stop early.

It returns a Generator, so put the call straight into a foreach loop. No request is issued until the first iteration, and breaking out of the loop leaves the remaining pages unfetched.

Example

php
use Envless\Envless;

$envless = new Envless();

foreach ($envless->projects->iterate(product: 'billing') as $project) {
    echo $project['slug'], PHP_EOL;
}

Parameters

ParameterTypeRequiredDescription
$productstringNoProduct slug or product uniqueId to restrict the stream to one product.
$limitintNoPage size fetched behind the scenes, clamped to 100.
$offsetintNoRow to start streaming from.
$searchstringNoCase insensitive substring match against project name and slug.
$orderstringNoDefaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt.
$timeoutint|floatNoSeconds 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 ProjectResource values until the pages run out.

Reads the projects 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 projects created mid walk can shift the window.
  • Use this rather than listAll when you only need the first match, since it stops fetching the moment you break.

Required scopes

projects:read

Underlying endpoint

GET /projects

Request and response schema, every error code, and a live playground.

In TypeScript

envless.projects.iterate()

The same method in @goenvless/sdk, with the same request, retries and errors.