Products

$envless->products->listProjects()

List the projects inside one product

php
/** @return Page<ProjectResource> */
public function listProjects(
    string $slug,
    ?int $limit = null,
    ?int $offset = null,
    ?string $search = null,
    ?string $order = null,
    int|float|null $timeout = null,
): Page

Fetches one page of the projects that belong to a single product. The rows match the flat project list filtered by product, but the scope comes from the path and the key needs both products:read and projects:read.

Prefer this over the workspace-wide project list whenever you care about one product: project slugs are unique per product only, so the flat list can hold the same slug more than once. A key restricted to projects in a different product returns an empty page instead of failing, so an empty items array is not proof that the product has no projects.

Example

php
use Envless\Envless;

$envless = new Envless();

$page = $envless->products->listProjects('billing', limit: 25);

foreach ($page->items as $project) {
    echo $project['slug'], ' ', $project['product']['slug'] ?? '', PHP_EOL;
}

Parameters

ParameterTypeRequiredDescription
$slugstringYesProduct slug, or the product uniqueId when the value is UUID shaped.
$limitintNoRows per page, a whole number from 1 to 100.
$offsetintNoRows to skip, a whole number of 0 or greater.
$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

Page<ProjectResource> holding items and the pagination envelope.

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

  • pagination['totalCount'] counts only the projects this key is allowed to see.

Required scopes

products:read and projects:read

Underlying endpoint

GET /products/{slug}/projects

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

In TypeScript

envless.products.listProjects()

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