/** @return \Generator<int, VersionEntryResource, mixed, void> */
public function iterateEntries(
string $project,
string $environment,
?int $limit = null,
?int $offset = null,
?string $product = null,
int|float|null $timeout = null,
): \GeneratorYields version entries individually, fetching the next page only once the current one is drained. Use it to rotate a large environment without holding its whole encrypted history in memory.
It returns a Generator, so put the call straight into a foreach loop. reencryptEntries rewrites only value and defaultValue and never adds or removes rows, so writing back mid stream does not shift the window. Publishing a version mid walk does shift it, because the new entries land in the same flat set.
Example
use Envless\Envless;
$envless = new Envless();
$ids = [];
foreach ($envless->versions->iterateEntries('api', 'production') as $entry) {
if ($entry['value'] !== null) {
$ids[] = $entry['id'];
}
}
echo count($ids), PHP_EOL;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
$project | string | Yes | Project slug or project uniqueId. |
$environment | string | Yes | Environment slug, since an environment uniqueId will not resolve here. |
$product | string | No | Product slug used to disambiguate a project slug shared across products. |
$limit | int | No | Page size fetched behind the scenes, clamped to 100. |
$offset | int | No | Row to start streaming from. |
$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
A Generator that yields VersionEntryResource values until the pages run out.
Reads the entries 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
- Buffer the yielded entries and write them back in batches. One
reencryptEntriescall per entry works but costs a request each. - Freeze publishing while a rotation walk is in flight, otherwise a new version adds entries encrypted under the old key after you have already passed that offset.
Required scopes
versions:read and variables:read
Underlying endpoint
GET /projects/{slug}/environments/{environmentSlug}/versions/entries
Request and response schema, every error code, and a live playground.
In TypeScript
envless.versions.iterateEntries()
The same method in @goenvless/sdk, with the same request, retries and errors.