An open API service indexing awesome lists of open source software.

https://github.com/upsun/upsun-sdk-php

Free and Open Source. SDK of Upsun. DISCLAIMER: This is a BETA version.
https://github.com/upsun/upsun-sdk-php

activation advocacy php-library sdk

Last synced: about 2 months ago
JSON representation

Free and Open Source. SDK of Upsun. DISCLAIMER: This is a BETA version.

Awesome Lists containing this project

README

          

# Upsun SDK PHP

The official **Upsun SDK for PHP**. This SDK provides a PHP interface that maps to the Upsun CLI commands.

For more information, read [the documentation](https://docs.upsun.com/api).

> **CAUTION**:
> This project is currently in **Beta**, meaning features and APIs may evolve over time.
>
> Please report bugs or request new features by creating a GitHub issue.

## Installation

Install the SDK via Composer:

```bash
composer require upsun/upsun-sdk-php
```

Then include Composer's autoloader in your PHP application:

```php
require __DIR__ . '/vendor/autoload.php';
```

## Authentication

You will need an [Upsun API token](https://docs.upsun.com/administration/cli/api-tokens.html) to use this SDK.
Store it securely, preferably in an environment variable.

```php
use Upsun\UpsunConfig;
use Upsun\UpsunClient;

$config = new UpsunConfig(apiToken: getenv('UPSUN_API_TOKEN'));
$upsunClient = new UpsunClient($config);
```

## Usage

### Example: List organizations

```php
$organizations = $upsunClient->organizations->list();
```

### Example: List projects in an organization

```php
$projects = $upsunClient->projects->list('');
```

### Example: Redeploy an environment

```php
$response = $upsunClient->environments->redeploy('', '');
```

---

## Development

Clone the repository and install dependencies:

```bash
git clone git@github.com:upsun/upsun-sdk-php.git
composer install
```

## Architecture of this SDK

The SDK is built as follows:

* From the [JSON specs of our API](https://docs.upsun.com/api/openapispec-upsun.json)
* Using [``@openapitools/openapi-generator-cli``](https://www.npmjs.com/package/%40openapitools/openapi-generator-cli)
* Which generates:
* PHP **Models** (in `src/Model/`)
* PHP **APIs** (in `src/Api/`)
* Higher-level PHP (Facade) oriented **Tasks** (in `src/Core/Tasks/`)

### Regenerating API & Model classes

API and Model classes are generated using [openapi-generator-cli](https://openapi-generator.tech)
from the [Upsun OpenAPI spec](https://docs.upsun.com/api/openapispec-upsun.json).

```bash
composer run spec:install
composer run spec:full
```

## Contributing

Contributions are welcome!

Please open a [pull request](https://github.com/upsun/upsun-sdk-php/compare) or an [issue](https://github.com/upsun/upsun-sdk-php/issues/new)
for any improvements, bug fixes, or new features.

## Tests

To run the tests, use:

```bash
composer install
composer run test
```

## License

This project is licensed under the Apache License 2.0. See the [LICENSE](https://github.com/upsun/upsun-sdk-php/blob/main/LICENSE) and [NOTICE](https://github.com/upsun/upsun-sdk-php/blob/main/NOTICE) files for details.