# POST /php/extensions/{name}

First published 14 Oct 2026 (release 0.2.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the php group.

Queue a job to turn a PHP extension on or off

- Who may call it: administrator
- Token scope, any of: settings, all
- Answers: 202 Accepted

Set on to true to install the extension package or false to remove it. Supply a nonempty array of installed PHP versions in versions, or use "all" to select every installed version where the extension can be changed to the requested state.

Returns 400 for an unknown extension or an invalid versions value. An explicit selection also returns 400 for an unknown or uninstalled PHP version, an extension supplied by PHP itself, or an attempt to turn on an extension that has no package for that version. Returns 409 if an explicitly selected version is already in the requested state, if "all" selects no eligible versions, or if a queued or running job for the same extension covers any selected version.

UrbeStack previews the package changes for every selected version before queuing a job. It refuses removals that would also remove a base package or another enabled extension. Each entry in refused gives the PHP version, the error, the proposed package changes in transaction, and blocked_by when available. If the preview refuses every version, the operation returns 409 with the refusals. Otherwise, it returns 202 with the php-ext job, the extension name, the requested state, the accepted versions, any refusals, and the additional extensions the package manager plans to install.

The job processes versions one at a time. After each package change, it reloads that version's PHP-FPM service, lets in-flight requests finish, and verifies the modules with php -m. The first failed or refused package change stops the job and marks the remaining versions as skipped. UrbeStack runs one PHP installation or extension change at a time.

## As commands

- [urbestack-php-ext-list](https://urbestack.com/docs/commands/urbestack-php-ext-list.md): Lists the PHP extension catalog for this server's distribution and shows each extension's state for every installed PHP version.
- [urbestack-php-ext-set](https://urbestack.com/docs/commands/urbestack-php-ext-set.md): Turns one extension in the PHP extension catalog on or off for one or more installed PHP versions.
- [urbestack-php-ext-set](https://urbestack.com/docs/commands/urbestack-php-ext-set.md): Turns one extension in the PHP extension catalog on or off for one or more installed PHP versions.

## Parameters

- `name` (path, string, matching ^[a-z][a-z0-9_]{0,31}$, required)

## Request body

JSON.

- `on` (boolean, required)
- `versions` (value, required): Array of installed PHP versions to change, or "all" for every installed version where the extension can be changed to the requested state.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/php/extensions/alice" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "on": true,
    "versions": "text"
  }'
```

Response, 202 Accepted:

```
{
  "brings": {},
  "job": {
    "created_at": "2026-09-09T10:15:00Z",
    "created_by": 1,
    "created_by_name": "text",
    "dismissed_at": "text",
    "finished_at": "2026-09-09T10:15:04Z",
    "id": 1,
    "lane": "short",
    "log": "",
    "params": {},
    "progress": 100,
    "result": {},
    "started_at": "2026-09-09T10:15:01Z",
    "status": "queued",
    "type": "rebuild",
    "usual_seconds": 1
  },
  "name": "alice",
  "on": true,
  "refused": [
    {
      "blocked_by": [
        "text"
      ],
      "error": "Domain 'example.com' already exists",
      "transaction": "text",
      "version": "0.0.1"
    }
  ],
  "versions": [
    "text"
  ]
}
```

## Errors

- 400: --q is a text of up to 64 characters
- 400: <name> is PHP itself in PHP <v> on this server: nothing to turn 
- 400: <name> is PHP itself in PHP <version> on this server (
- 400: <name> is not an extension this server's distribution packages for PHP
- 400: <name> is not packaged for PHP <v> on this server's repositories
- 400: A new job is queued or running
- 400: Invalid <what>: 
- 400: Invalid <what>: expected a non-negative integer
- 400: Invalid PHP version, expected e.g. 8.2
- 400: Invalid extension name '
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Job parameters must be an object
- 400: Name at least one version
- 400: Name the versions (--version, repeatable) or say --all-versions
- 400: No extension named '<n>' in the catalog; urbestack-php-ext-list prints it
- 400: No extension named '<name>' in this server's catalog
- 400: PHP <_> is not installed on this server
- 400: PHP <v> is not installed on this server
- 400: Say --on or --off
- 400: Unknown PHP version '
- 400: Unknown PHP version '<v>'
- 400: Unknown PHP version '<version>'
- 400: Unknown job type
- 400: Username '<value>' is reserved
- 400: versions is a list of installed versions, or "all"
- 401: Authentication required
- 404: User '<user>' not found
- 409: <name> is 
- 409: <name> is already being turned 
- 409: Another PHP installation is already running
