Variables

$envless->variables->listAll()

Collect every variable in an environment

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

Walks every page and returns a single array of the live variables in an environment. Requests run one after another until hasMore turns false, so a large environment costs one round trip per 100 variables and the entire set is held in memory at once.

limit: is the page size here, not a total cap, and it is clamped to 100. offset: sets where the walk starts, so a non-zero value silently drops the variables before it.

There is no partial result. An exception midway through the walk discards the pages already fetched, so budget for the whole thing succeeding or nothing.

Example

php
use Envless\Envless;

$envless = new Envless();

$variables = $envless->variables->listAll('api', 'production');

echo count($variables), PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug the environment belongs to.
$environmentstringYesEnvironment slug to read variables from.
$limitintNoPage size for each underlying request, clamped to 100.
$offsetintNoOffset the walk starts from, defaults to 0.
$productstringNoProduct slug, needed when the project slug is not unique in the workspace.
$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<VariableResource> with every live variable in the environment, values still ciphertext.

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

  • Use this to build the baseline for apply, since the drift check needs every live variable and not just a page.

Required scopes

variables:read

Underlying endpoint

GET /projects/{slug}/environments/{environmentSlug}/variables

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

In TypeScript

envless.variables.listAll()

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