Download the PHP package boudhraadhia7/vultr-php-sdk without Composer

On this page you can find all versions of the php package boudhraadhia7/vultr-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package vultr-php-sdk

Vultr PHP SDK

CI Latest version PHP version

A typed PHP client for the Vultr API v2.

It covers instances, DNS, firewalls, block and object storage, snapshots, backups, SSH keys, startup scripts, reserved IPs, ISOs, users, and the read-only catalogues (regions, plans, operating systems, applications). Cursor pagination, retries and error handling are built in.

Installation

Quick start

Create an API key in the Vultr customer portal under Account > API, and add the IP addresses that will use it to the key's access control list.

Resources

Each resource group hangs off the client:

Accessor Covers
$vultr->account() Account details, balance, bandwidth
$vultr->instances() Instances: lifecycle, addresses, backups, ISO, VPC
$vultr->regions() Regions and per-region plan availability
$vultr->plans() Cloud compute and bare metal plans
$vultr->operatingSystems() Deployable OS images
$vultr->applications() One-click and Marketplace applications
$vultr->snapshots() Snapshots, including import from a URL
$vultr->backups() Automatic backups (read-only)
$vultr->sshKeys() SSH public keys
$vultr->startupScripts() Boot and PXE scripts
$vultr->reservedIps() Reserved (floating) IPs
$vultr->isos() Custom and public ISO images
$vultr->blockStorage() Block storage volumes
$vultr->domains() Managed DNS: zones, records, SOA, DNSSEC
$vultr->objectStorage() S3-compatible object storage
$vultr->firewalls() Firewall groups and rules
$vultr->users() Sub-account users and ACLs

Creating an instance

InstanceBuilder validates the payload before a request leaves your process, so a missing plan or two conflicting deployment sources fail immediately rather than as a 400 from the API.

Every builder method returns a new builder, so a partially configured one works as a reusable template:

Deploy from a snapshot, ISO, one-click app or Marketplace image with fromSnapshot(), fromIso(), fromApplication() or fromMarketplaceApp(). Choosing a second source replaces the first rather than sending both.

Anything the builder does not model goes through set():

Managing instances

Instance ids are always passed explicitly:

Backup schedules are enum-typed, and the fields a cadence requires are checked before the request is sent:

Pagination

Every collection endpoint offers two shapes.

list() returns one Page, which is countable, iterable and carries the cursors, for when you are paging in a UI:

all() returns a generator that walks every page for you, fetching lazily:

Error handling

Failures throw. There is nothing to check on the return value.

The hierarchy:

Every ApiException carries statusCode(), errorBody(), request() and response(). The Authorization header on request() is already redacted, so the exception is safe to log as-is.

Retries

Rate limits, 5xx responses and transport failures are retried with exponential backoff and full jitter. A Retry-After header is honoured when present, capped at the configured maximum delay.

Only idempotent methods (GET, HEAD, PUT, DELETE) are replayed after a 5xx or a transport failure, so a POST that may have already created an instance is never sent twice. A 429 is replayed for any method, because a rate-limited request was rejected before it was processed.

Configuration

Config is immutable: every with*() call returns a new instance, so one configured object can be shared between clients and workers.

Method Default Purpose
Config::create($key, $baseUri) https://api.vultr.com/ Build from an API key
Config::fromEnvironment($var) VULTR_API_KEY Read the key from the environment
withTimeout(float) 30.0 Seconds for the whole transfer
withConnectTimeout(float) 10.0 Seconds to establish the connection
withMaxRetries(int) 2 Retry attempts for retryable failures
withRetryDelays(float, float) 0.5, 8.0 Backoff base and ceiling, in seconds
withDefaultHeaders(array) [] Headers added to every request
withCaBundle(string) system store Path to a CA bundle file or directory

TLS

Certificate verification is always on and cannot be disabled. If a machine cannot verify Vultr's certificate, point the client at a valid CA bundle rather than turning verification off:

Framework integration

The client is a plain object with no framework coupling. Register it once as a singleton and type-hint it where you need it.

Laravel — in a service provider:

Symfony — in config/services.yaml:

Using your own HTTP stack

Pass a Psr18HttpClient to share your application's client, middleware and logging with the SDK. This needs psr/http-client and psr/http-factory, which are optional dependencies of this package.

To test without the network, implement HttpClientInterface yourself; it has a single send(Request): Response method.

Endpoints not yet modelled

Vultr ships new endpoints regularly. Call them directly and keep the authentication, retries, error mapping and JSON decoding:

Examples

Runnable scripts live in examples/:

File Shows
01-list-instances.php Account summary, lazy pagination, byte formatting
02-create-instance.php Building and deploying an instance, polling until ready
03-error-handling.php The exception hierarchy in practice
04-dns-and-firewall.php DNS records and firewall rules with enum parameters
05-framework-integration.php Laravel, Symfony and PSR-18 wiring

Upgrading from 1.x

Version 2.0 is a rewrite with a new namespace and a new API surface. See UPGRADE.md for a method-by-method mapping and CHANGELOG.md for the full list of changes, including the correctness bugs 1.x shipped with.

Development

Contributions are welcome; see CONTRIBUTING.md.

Security

Report vulnerabilities privately. See SECURITY.md.

License

MIT. See LICENSE.

This package began as a fork of cp6/Vultr-API-PHP-class by corbpie, and has since been rewritten.


All versions of vultr-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-curl Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package boudhraadhia7/vultr-php-sdk contains the following files

Loading the files please wait ...