transip/transip-api-symfony 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

transip/transip-api-symfony

最新稳定版本:v1.1.1

Composer 安装命令:

composer require transip/transip-api-symfony

包简介

TransIP API client integration for Symfony

README 文档

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 (php extension)
  • openssl (php extension)

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

统计信息

  • 总下载量: 433
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 6
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-11-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固