Environments

$envless->environments->listAll()

Collect every environment in a project

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

Walks every page of the environments in a project and returns one flat array. limit sets the page size, capped at 100, not the number of rows you get back, so raising or lowering it changes the request count and nothing else.

All rows are buffered in memory before the call returns, and each row has the same fields list returns, exposed and updatedAt included. Environment counts are small by design, since the allowance is per project rather than per workspace, so this is usually the read you want.

Example

php
use Envless\Envless;

$envless = new Envless();

$environments = $envless->environments->listAll('api');

echo count($environments), PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug or uniqueId that owns the environments.
$productstringNoProduct slug that disambiguates an ambiguous project slug.
$limitintNoPage size used for each underlying request, capped at 100.
$offsetintNoRows to skip before collection starts.
$searchstringNoCase insensitive substring match on the environment name or slug.
$orderstringNoasc or desc sorts by creation time, oldest or newest first. Anything else, or nothing, sorts by name.
$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

list<EnvironmentSummaryResource> with one entry per environment in the project.

Reads the environments 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

  • An ambiguous project slug fails on the first request, so nothing is collected and no partial array is returned.
  • A timeout on any page fails the whole call; there is no partial result to recover.

Required scopes

environments:read

Underlying endpoint

GET /projects/{slug}/environments

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

In TypeScript

envless.environments.listAll()

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