/** @return list<VariableResource> */
public function listAll(
string $project,
string $environment,
?int $limit = null,
?int $offset = null,
?string $product = null,
int|float|null $timeout = null,
): arrayWalks 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
use Envless\Envless;
$envless = new Envless();
$variables = $envless->variables->listAll('api', 'production');
echo count($variables), PHP_EOL;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$project | string | Yes | Project slug the environment belongs to. |
$environment | string | Yes | Environment slug to read variables from. |
$limit | int | No | Page size for each underlying request, clamped to 100. |
$offset | int | No | Offset the walk starts from, defaults to 0. |
$product | string | No | Product slug, needed when the project slug is not unique in the workspace. |
$timeout | int|float | No | Seconds 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
baselineforapply, 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.