Environments

$envless->environments->list()

List one page of environments in a project

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

Returns one page of the environments in a project, sorted by name A to Z, as items plus a pagination envelope. The project argument resolves as a uniqueId first and then as a slug. Project slugs are only unique inside a product, so set product: whenever the same project slug exists in two products, otherwise the call fails with project.ambiguous_product before it ever looks at environments.

search matches environment name and slug, and order defaults to name, which sorts A to Z, with asc and desc sorting oldest and newest first on createdAt. Each row carries id, name, slug, projectId, exposed, createdAt and updatedAt, the same fields get returns.

Example

php
use Envless\Envless;

$envless = new Envless();

$page = $envless->environments->list('api', product: 'billing', limit: 50);

echo $page->pagination['totalCount'], PHP_EOL;

foreach ($page->items as $environment) {
    echo $environment['slug'], PHP_EOL;
}

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug or uniqueId that owns the environments.
$productstringNoProduct slug that disambiguates an ambiguous project slug.
$limitintNoRows per page, a whole number between 1 and 100.
$offsetintNoRows to skip before the page 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

Page<EnvironmentSummaryResource> holding the rows in items and the counts in pagination.

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

  • A limit outside 1 to 100 is rejected with request.invalid_pagination rather than clamped.
  • A 404 here means no project matched in scope for this key, not that the project has no environments.

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.list()

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