Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/transip/transip-api-symfony

This bundle provides an instance of TransipAPI to Symfony's Container.
https://github.com/transip/transip-api-symfony

api bundle rest symfony transip

Last synced: 2 months ago
JSON representation

This bundle provides an instance of TransipAPI to Symfony's Container.

Awesome Lists containing this project

README

        



# TransIP RestAPI bundle for Symfony

This bundle provides an instance of `\Transip\Api\Library\TransipAPI` to Symfony's Container.

## Requirements

The TransIP RestAPI bundle for Symfony requires the following in order to work properly:

* PHP >= 8.0
* [json](https://www.php.net/manual/en/book.json.php) (php extension)
* [openssl](https://www.php.net/manual/en/book.openssl.php) (php extension)

## Installation
You can install the RestAPI library using [Composer](http://getcomposer.org/). Run the following command:
```bash
composer require transip/transip-api-symfony
```

Then register your bundle in Symfony
```diff
['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
+ Transip\Bundle\RestApi\TransipApiBundle::class => ['all' => true],
];

```

Lastly create a config file:
```yaml
# config/packages/transip.yaml
transip_api:
options:
generateWhitelistOnlyTokens: true
authentication:
username: '%env(TRANSIP_USERNAME)%' # The username you use to login onto the Control Panel
privateKey: '%env(TRANSIP_PRIVATE_KEY)%' # Your Private Key create from the Control Panel
````

## Getting started
```php
vps()->getAll();

// Authenticate client with Token (account #1)
$apiClient->setToken('some.jwt.token');

// Get all VPSes for account #1
$apiClient->vps()->getAll();

// Request Token with username and private key (account #2)
$token = $apiClient->auth()->createToken(
$transipUsername,
$transipPrivateKey,
false, // Create IP Whitelisted tokens
false, // Create a read only token
'' // Add Token label
'1 day' // Create token expire
);
// Set token in library
$apiClient->setToken($token);

// Get all VPSes for account #2
$apiClient->vps()->getAll();
}
}
```

## Use client
For more information about using the TransIP API Client, please look [at its documentation](https://github.com/transip/transip-api-php#get-all-domains)