Primary IPs
Provision static primary interface IPs.
Hetzner::primaryIps()->all();
Hetzner Cloud
v1.0.0
Documentation v1.0.0
The Laravel Hetzner Cloud SDK provides a production-ready client interface for managing cloud servers, volumes, networks, firewalls, and load balancers. Compatible with PHP 8.2 through 8.5, and Laravel 11 through 13.
Install the package through Composer:
composer require ghostcompiler/laravel-hetzner-cloud
Publish the configuration assets:
php artisan vendor:publish --provider="Vendor\HetznerCloud\Providers\HetznerCloudServiceProvider" --tag="config"
The published configuration file lives at config/hetzner-cloud.php. You can generate your API Token from the Hetzner Cloud Console under project Security settings.
return [
'token' => env('HETZNER_CLOUD_TOKEN'),
'base_url' => env('HETZNER_CLOUD_BASE_URL', 'https://api.hetzner.cloud/v1'),
'timeout' => (int) env('HETZNER_CLOUD_TIMEOUT', 30),
'retries' => (int) env('HETZNER_CLOUD_RETRIES', 3),
'retry_backoff' => (int) env('HETZNER_CLOUD_RETRY_BACKOFF', 100),
'logging' => [
'enabled' => (bool) env('HETZNER_CLOUD_LOGGING_ENABLED', false),
'channel' => env('HETZNER_CLOUD_LOGGING_CHANNEL'),
],
];
The service provider binds the singleton client and orchestrator to Laravel's service container.
use Vendor\HetznerCloud\Managers\HetznerManager;
$manager = app(HetznerManager::class);
$servers = $manager->servers()->all();
Interact with the SDK fluently using the Facade accessor.
use Vendor\HetznerCloud\Facades\Hetzner;
$server = Hetzner::servers()->find(123);
Manage VM instances, trigger power status controls, attach networks, and boot rescue environments.
// List servers
$servers = Hetzner::servers()->all();
// Create server
$response = Hetzner::servers()->create([
'name' => 'web-01',
'server_type' => 'cx22',
'image' => 'ubuntu-24.04',
'location' => 'fsn1',
]);
Attach SSD block storage disks to servers.
$volumes = Hetzner::volumes()->all();
Hetzner::volumes()->attach($volumeId, $serverId);
Private IP infrastructure networks for server communication.
$networks = Hetzner::networks()->all();
Configure stateless inbound and outbound security rules.
Hetzner::firewalls()->apply($firewallId, $serverId);
Allocate highly available IP addresses routing to servers dynamically.
Hetzner::floatingIps()->assign($ipId, $serverId);
Provision static primary interface IPs.
Hetzner::primaryIps()->all();
Traffic distribution proxies for targets cluster pools.
Hetzner::loadBalancers()->addTarget($lbId, ['type' => 'server', 'server' => ['id' => $serverId]]);
Authentication credentials for VM deployments.
Hetzner::sshKeys()->create(['name' => 'key', 'public_key' => 'ssh-rsa...']);
OS base distributions and backups snapshots.
$images = Hetzner::images()->all();
TLS keys configuration storage.
Hetzner::certificates()->all();
Server scheduling spread layout policies.
Hetzner::placementGroups()->create(['name' => 'grp', 'type' => 'spread']);
Read geographical server centers.
$locs = Hetzner::locations()->all();
Information on physical facilities.
$dcs = Hetzner::datacenters()->all();
Optical disk installations catalog.
$isos = Hetzner::isos()->all();
List product pricing rates.
$pricing = Hetzner::pricing()->all();
Lifecycle action history.
$actions = Hetzner::actions()->all();
Available VM hardware configurations.
$types = Hetzner::serverTypes()->all();
Capacity limits configurations for load balancers.
$lbTypes = Hetzner::loadBalancerTypes()->all();
Configure queries asynchronously to yield Guzzle Promises.
$promise = Hetzner::servers()->async()->all();
$servers = $promise->wait();
Run calls concurrently in pooled execution tasks.
$results = Hetzner::batch([
fn () => Hetzner::servers()->find(1),
fn () => Hetzner::servers()->find(2),
]);
Request pipeline is governed by automatic Guzzle middleware.
HTTP error codes automatically map to specific PHP exception classes.
try {
Hetzner::servers()->find(999);
} catch (\Vendor\HetznerCloud\Exceptions\NotFoundException $e) {
// 404 Error
}
Quick copy reference table for common helper methods.
Hetzner::ping();
Hetzner::version();
Hetzner::rateLimit();
Hetzner::health();
Hetzner::config();
Hetzner::client();
Yes. Change credentials dynamically using Hetzner::authenticate($token).
Use paginate(perPage, page). It returns a PaginatedResponse wrapper including the items collection and PaginationMeta DTO.