Versions

$envless->versions->listAll()

Collect every version of an environment

php
/** @return list<VersionResource> */
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 the flattened array of versions, newest first. An environment is capped at 1000 versions on every plan, so the result stays bounded even on a long lived project.

limit: is the page size used while walking, not a cap on how many versions come back: a limit of 5 still returns the whole history, just in more round trips. It is clamped to the API maximum of 100, so asking for more buys nothing.

Example

php
use Envless\Envless;

$envless = new Envless();

$versions = $envless->versions->listAll(
    'api',
    'production',
    product: 'billing',
);

echo count($versions), ' ', $versions[0]['label'] ?? 'none yet', PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$projectstringYesProject slug or project uniqueId.
$environmentstringYesEnvironment slug, since an environment uniqueId will not resolve here.
$productstringNoProduct slug used to disambiguate a project slug shared across products.
$limitintNoPage size used while walking, clamped to 100.
$offsetintNoRow to start the walk from.
$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<VersionResource> holding every snapshot taken for the environment.

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

  • Nothing is returned until the final page lands. Use iterate when you want to act on versions as they arrive.
  • Rows carry variableCount only, so reading the values behind every version costs one $envless->versions->get() per row.
  • On the Free plan only the latest version is listed; the older ones are stored but need Dev or above to be read, and reading one there is 402 plan.upgrade_required.

Required scopes

versions:read

Underlying endpoint

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

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

In TypeScript

envless.versions.listAll()

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