Projects

$envless->projects->listAll()

Collect every reachable project into one array

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

Walks every page for you and returns the flattened result. Use it when the workspace is small enough that holding all projects in memory is fine and you would rather not manage offsets.

The trap is limit:, which here sets the page size used while walking, not a cap on how many projects come back. Asking for a limit of 5 still returns everything, just in more round trips. Duplicate slugs across products survive into the array, so continue keying off id.

Example

php
use Envless\Envless;

$envless = new Envless();

$projects = $envless->projects->listAll(search: 'api');

echo count($projects), PHP_EOL;

Parameters

ParameterTypeRequiredDescription
$productstringNoProduct slug or product uniqueId to restrict the walk to one product.
$limitintNoPage size used while walking, clamped to 100.
$offsetintNoRow to start the walk from.
$searchstringNoCase insensitive substring match against project name and slug.
$orderstringNoDefaults to name, which sorts A to Z. Pass asc for oldest first or desc for newest first on createdAt.
$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<ProjectResource> holding every project the key can reach.

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

  • Page size defaults to the API maximum of 100 and is clamped there, so a larger limit buys nothing.
  • Nothing is returned until the final page lands. Prefer iterate when you want to act on rows as they arrive.

Required scopes

projects:read

Underlying endpoint

GET /projects

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

In TypeScript

envless.projects.listAll()

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