Laravel Meets Hetzner: Spin Up Cloud Servers with Just One Line of Code


Laravel developers now have a powerful, type-safe way to manage Hetzner Cloud resources — thanks to the new Hetzner SDK for Laravel. Whether you’re spinning up servers, configuring DNS, or managing load balancers, this package brings full API coverage with clean syntax and deep Laravel integration.


🧠 What Is the Hetzner SDK for Laravel?

Developed by amar8eka, this SDK wraps the entire Hetzner Cloud API in a Laravel-friendly interface. It’s built for Laravel v12+, and includes:

  • Full API coverage: Servers, DNS, networks, load balancers, volumes, and more
  • Type-safe architecture: Built for PHP 8.2+
  • Laravel-native features: Service provider, facade, and testing utilities
  • Meta info access: Rate limits, request details, and more

⚙️ Quick Start Example

Here’s how easy it is to create a server:

use Boci\HetznerLaravel\HetznerClient;

$client = HetznerClient::factory()
    ->withApiKey('your-api-token')
    ->make();

$response = $client->servers()->create([
    'name' => 'my-server',
    'server_type' => 'cpx11',
    'image' => 'ubuntu-24.04',
    'location' => 'nbg1',
]);

$server = $response->server();
$action = $response->action();
$rootPassword = $response->rootPassword();

echo "Server ID: " . $server->id();
echo "Server Name: " . $server->name();
echo "Status: " . $server->status();
echo "Root Password: " . $rootPassword;

You get structured responses, full control, and readable syntax — no raw curl calls or manual JSON parsing.


🧪 Facade Support

Prefer Laravel’s facade style? You’re covered:

use Boci\HetznerLaravel\Facades\HetznerLaravel as Hetzner;

Hetzner::servers()->list();
Hetzner::servers()->retrieve('12345');
Hetzner::servers()->delete('12345');

This makes it easy to integrate Hetzner operations into controllers, jobs, or service classes.


🧰 Testing Made Easy

The SDK includes a ClientFake for mocking API calls during testing:

$fake = new ClientFake();
$fake->servers()->create([...]); // returns a mock response

You can simulate server creation, deletion, and other actions without hitting the real API — perfect for CI pipelines and unit tests.


🔐 Why It Matters

If you’re deploying Laravel apps to Hetzner Cloud, this SDK gives you:

  • Cleaner infrastructure automation
  • Faster provisioning workflows
  • Better DX for cloud-native Laravel apps

It’s ideal for SaaS platforms, internal tools, or any Laravel project that needs scalable cloud resources.


📦 Final Thought

The Hetzner SDK for Laravel turns cloud infrastructure into a first-class citizen in your Laravel app. With full API coverage, elegant syntax, and Laravel-native features, it’s a must-have for developers building on Hetzner.

👉 Explore the package on GitHub
📰 Read the original announcement on Laravel News


References (1)

1Hetzner SDK for Laravel – Laravel News. https://laravel-news.com/hetzner-sdk-for-laravel

Leave a Reply

Your email address will not be published. Required fields are marked *