AMAR BEKA.

[ OPEN SOURCE ]

Hetzner SDK for Laravel

A Laravel SDK for Hetzner Cloud that covers the whole API, types every response, and fakes cleanly in tests.

Hetzner is where a lot of European infrastructure quietly lives, and its API is good. What was missing was a Laravel-shaped way into it: something with a service provider, a facade, real types on the way back, and a way to test against it without touching a live account. That is what this package is.

Installing it

composer require boci/hetzner-laravel

It targets PHP 8.2+ and Laravel 12+. The service provider registers itself, so after the install there is a `Hetzner` facade and a config file, and nothing else to wire up.

What it covers

Every resource the Hetzner Cloud API exposes, not a convenient subset: actions, billing, certificates, DNS zones, firewalls, floating IPs, images, ISOs, load balancers and load balancer types, locations, networks, placement groups, primary IPs, servers and server types, SSH keys, and volumes.

The reason for going all the way is that a partial SDK is worse than none. The moment you hit the resource it does not cover you are back to writing raw requests, and now you have two ways of talking to the same API in one codebase.

What using it looks like

A client is built from a factory and an API token, and every resource hangs off it — $client->servers()->create([...]) provisions a machine, and the response that comes back is an object with methods on it rather than an associative array to guess at.

Most application code goes through the facade instead: HetznerLaravel::servers()->list() reads the way the documentation does. The rate-limit and request metadata arrive alongside the data rather than being thrown away.

The full examples, formatted properly, are on the open-source page of this site and in the README.

Testing against it

The package ships a `ClientFake`, so a test that provisions a server does not provision a server. That is the part that decides whether an SDK is pleasant to live with: infrastructure code that cannot be tested cheaply is infrastructure code nobody refactors.

Where it is

Source and documentation: github.com/amar8eka/hetzner-laravel

Laravel News covered the release: laravel-news.com/hetzner-sdk-for-laravel

← WRITING