transip / transip-api-symfony
TransIP API client integration for Symfony
Installs: 310
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.0
- nyholm/psr7: ^1.4
- php-http/client-common: ^1.6 || ^2.0
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.1 || ^2.0
- psr/http-client: ^1.0
- symfony/config: ^4.4 || ^5.4 || ^6.4 || ^7.0
- symfony/dependency-injection: ^4.4 || ^5.4 || ^6.4 || ^7.0
- symfony/http-kernel: ^4.4 || ^5.4 || ^6.4 || ^7.0
- transip/transip-api-php: ^6.25
Requires (Dev)
- dg/bypass-finals: ^1.3
- phpstan/phpstan: ^0.12.99
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- symfony/http-client: ^4.4 || ^5.4 || ^6.4 || ^7.0
This package is auto-updated.
Last update: 2024-11-15 14:59:38 UTC
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:
Installation
You can install the RestAPI library using Composer. Run the following command:
composer require transip/transip-api-symfony
Then register your bundle in Symfony
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['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:
# 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 // src/Controller/TransIPApiController.php namespace App\Controller; use Symfony\Component\HttpFoundation\Response; use Transip\Api\Library\TransipAPI; class TransIPApiController { public function getVpses( TransipAPI $apiClient ): Response { // Get all VPSes for account #0 (authentication in config) $apiClient->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