> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP SDK - Installation

> Install the Westyx Nexus PHP SDK via Composer, including repository configuration.

The PHP SDK is published to the GitLab Composer registry. Because GitLab-hosted Composer packages are not indexed by Packagist, you must add a `repositories` entry to your `composer.json` before running `composer require`.

## Repository configuration

Add the following to your `composer.json` before installing:

```json theme={null}
{
    "repositories": [
        {
            "type": "composer",
            "url": "https://gitlab.com/api/v4/projects/82742835/packages/composer/packages.json"
        }
    ]
}
```

## Install

```sh theme={null}
composer require westyx/nexus
```

Pin a specific version (recommended for production services):

```sh theme={null}
composer require westyx/nexus:^0.10.0
```

Add the autoload import to your bootstrap:

```php theme={null}
require_once __DIR__ . '/vendor/autoload.php';

use WestyxNexus\NexusClient;
use WestyxNexus\NexusConfig;
```

## Requirements

* **PHP 8.3** or newer (PHP 8.1 and 8.2 are end-of-life)
* **Composer 2** - Composer 1 is not tested and is no longer supported upstream
* **Guzzle 7** (`guzzlehttp/guzzle ^7.0`) - installed automatically as a dependency
* Network access to `<your-slug>.westyx.dev` at runtime

<Note>
  Guzzle 7 requires `guzzlehttp/promises ^2.0` and `guzzlehttp/psr7 ^2.0`. Composer resolves these transitively - you do not need to declare them explicitly.
</Note>

## Full `composer.json` example

```json theme={null}
{
    "require": {
        "php": ">=8.3",
        "westyx/nexus": "^0.10.0"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://gitlab.com/api/v4/projects/82742835/packages/composer/packages.json"
        }
    ]
}
```

## Verifying installation

```sh theme={null}
composer show westyx/nexus
```

Should print a block containing:

```
name     : westyx/nexus
versions : * 0.9.0
```

If you see an older version, run `composer update westyx/nexus` to upgrade.

## Verifying connectivity

Before writing any code, confirm your endpoint and API key work with a plain `curl`:

```sh theme={null}
curl -s \
  -H "X-Nexus-API-Key: wxs_..." \
  https://your-service.westyx.dev/v1/sync
```

A valid response returns a JSON snapshot with your `configs`, `secrets`, and `flags`. An `HTTP 401` means the key is wrong; `HTTP 404` means the slug is wrong.

To watch the live SSE stream:

```sh theme={null}
curl -N \
  -H "X-Nexus-API-Key: wxs_..." \
  -H "Accept: text/event-stream" \
  https://your-service.westyx.dev/v1/stream
```

You should see `event:resync` arrive within a second. Press `Ctrl+C` to stop.

## Troubleshooting

<Warning>
  The `repositories` entry must be present **before** running `composer require`. If you add it after, Composer will not retry the lookup - remove the cached resolution from `composer.lock` and run `composer install` again.
</Warning>

* **`Could not find package westyx/nexus`** - verify the `repositories` URL is in `composer.json` and that your build machine can reach `gitlab.com`.
* **`Your requirements could not be resolved`** - check that your declared `php` version constraint allows 8.3+. Run `php -v` to confirm the active runtime version.
* **SSL certificate errors** - Guzzle uses the system CA bundle. On Alpine Linux or minimal Docker images, install `ca-certificates` (`apk add ca-certificates`).
* **`Class WestyxNexus\NexusClient not found`** - ensure `require_once __DIR__ . '/vendor/autoload.php'` runs before any `use` statement.
