Products

$envless->products->listAllProjects()

Collect every project in a product

php
/** @return list<ProjectResource> */
public function listAllProjects(
    string $slug,
    ?int $limit = null,
    ?int $offset = null,
    ?string $search = null,
    ?string $order = null,
    int|float|null $timeout = null,
): array

Walks every page of the projects in a product and returns one flat array. Requests use the maximum page size of 100 until the API reports no more rows.

The pagination envelope is dropped, so call listProjects once when you need totalCount. An unknown product, or a private one with no grant, throws here rather than returning an empty array, which makes this a cheap existence check as well.

Example

php
use Envless\Envless;

$envless = new Envless();

$projects = $envless->products->listAllProjects('billing');

foreach ($projects as $project) {
    echo $project['slug'], PHP_EOL;
}

Parameters

ParameterTypeRequiredDescription
$slugstringYesProduct slug, or the product uniqueId when the value is UUID shaped.
$limitintNoPage size for each underlying request, capped at 100.
$offsetintNoRow to start the walk 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

An list<ProjectResource> with every project in the product the key can see.

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

  • Each returned project still carries its own product summary, so the array is safe to concatenate across products.

Required scopes

products:read and projects:read

Underlying endpoint

GET /products/{slug}/projects

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

In TypeScript

envless.products.listAllProjects()

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