PHPackages                             boci/hetzner-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. boci/hetzner-laravel

ActiveLibrary[API Development](/categories/api)

boci/hetzner-laravel
====================

A Laravel SDK for interacting with the Hetzner Cloud API - inspired by Nuno Maduro's OpenAI PHP client

v1.0.2(8mo ago)912.2k↑265.4%4MITPHPPHP ^8.2CI passing

Since Oct 19Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/amar8eka/hetzner-laravel)[ Packagist](https://packagist.org/packages/boci/hetzner-laravel)[ Docs](https://github.com/amar8eka/hetzner-laravel)[ RSS](/packages/boci-hetzner-laravel/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (3)Dependencies (8)Versions (4)Used By (0)

Hetzner Laravel
===============

[](#hetzner-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/162f1309b15a924daac8657a19c660a859c72692b0f1c92f3fcb530666538f48/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f626f63692f6865747a6e65722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/boci/hetzner-laravel)[![Total Downloads](https://camo.githubusercontent.com/a8fb7d4ca4edaf498aa642e14b55281266fe6165690875b0d93488a6ed5ae996/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f626f63692f6865747a6e65722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/boci/hetzner-laravel)[![GitHub Actions](https://github.com/amar8eka/hetzner-laravel/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/amar8eka/hetzner-laravel/actions/workflows/main.yml)

⚡️ **Hetzner Laravel** is a supercharged community-maintained Laravel SDK that allows you to interact with the Hetzner Cloud API. Inspired by Nuno Maduro's excellent [OpenAI PHP client](https://github.com/openai-php/client).

Features
--------

[](#features)

- 🚀 **Modern Architecture**: Clean, organized, and maintainable code structure
- 🧪 **Testing Ready**: Includes `ClientFake` for easy testing and mocking
- 📊 **Meta Information**: Access rate limits and request details
- 🛡️ **Type Safe**: Full type safety with PHP 8.2+
- 🎯 **Resource Based**: Clean, organized API resources
- 🔧 **Laravel Integration**: Seamless Laravel service provider and facade
- 🌐 **Complete API Coverage**: All Hetzner Cloud API endpoints implemented

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require boci/hetzner-laravel
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="Boci\HetznerLaravel\HetznerLaravelServiceProvider" --tag="config"
```

Add your Hetzner API token to your `.env` file:

```
HETZNER_TOKEN=your-hetzner-api-token-here
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Boci\HetznerLaravel\Client;

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

// Create a server
$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;
```

### Using the Facade

[](#using-the-facade)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List all servers
$servers = HetznerLaravel::servers()->list();

foreach ($servers->servers() as $server) {
    echo "Server: " . $server->name() . " - " . $server->status() . "\n";
}

// Get server details
$server = HetznerLaravel::servers()->retrieve('12345');
echo "Server IP: " . $server->server()->publicNet()['ipv4']['ip'];

// Delete a server
$action = HetznerLaravel::servers()->delete('12345');
echo "Delete action status: " . $action->action()->status();
```

### Working with Images

[](#working-with-images)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List available images
$images = HetznerLaravel::images()->list();

foreach ($images->images() as $image) {
    echo "Image: " . $image->name() . " - " . $image->osFlavor() . "\n";
}

// Get specific image details
$image = HetznerLaravel::images()->retrieve('12345');
echo "Image size: " . $image->image()->imageSize() . " GB";
```

### Working with Locations

[](#working-with-locations)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List available locations
$locations = HetznerLaravel::locations()->list();

foreach ($locations->locations() as $location) {
    echo "Location: " . $location->name() . " - " . $location->city() . ", " . $location->country() . "\n";
}
```

### Working with Server Types

[](#working-with-server-types)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List available server types
$serverTypes = HetznerLaravel::serverTypes()->list();

foreach ($serverTypes->serverTypes() as $serverType) {
    echo "Server Type: " . $serverType->name() . " - " . $serverType->cores() . " cores, " . $serverType->memory() . " GB RAM\n";
}
```

### Working with Networks

[](#working-with-networks)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List all networks
$networks = HetznerLaravel::networks()->list();

foreach ($networks->networks() as $network) {
    echo "Network: " . $network->name() . " - " . $network->ipRange() . "\n";
}

// Create a new network
$response = HetznerLaravel::networks()->create([
    'name' => 'my-network',
    'ip_range' => '10.0.0.0/16',
]);

$network = $response->network();
echo "Created network: " . $network->name();
```

### Working with Load Balancers

[](#working-with-load-balancers)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List all load balancers
$loadBalancers = HetznerLaravel::loadBalancers()->list();

foreach ($loadBalancers->loadBalancers() as $lb) {
    echo "Load Balancer: " . $lb->name() . " - " . $lb->loadBalancerType()->name() . "\n";
}

// Create a load balancer
$response = HetznerLaravel::loadBalancers()->create([
    'name' => 'my-lb',
    'load_balancer_type' => 'lb11',
    'location' => 'nbg1',
]);

$loadBalancer = $response->loadBalancer();
echo "Created load balancer: " . $loadBalancer->name();
```

### Working with DNS

[](#working-with-dns)

```
use Boci\HetznerLaravel\Facades\HetznerLaravel;

// List DNS zones
$zones = HetznerLaravel::dnsZones()->list();

foreach ($zones->zones() as $zone) {
    echo "Zone: " . $zone->name() . " - " . $zone->status() . "\n";
}

// Create a DNS zone
$response = HetznerLaravel::dnsZones()->create([
    'name' => 'example.com',
    'mode' => 'primary',
    'ttl' => 3600,
]);

$zone = $response->zone();
echo "Created zone: " . $zone->name();

// List DNS records for a zone
$rrsets = HetznerLaravel::dnsZones()->rrsets()->list('example.com');

foreach ($rrsets->rrsets() as $rrset) {
    echo "Record: " . $rrset->name() . " " . $rrset->type() . " " . $rrset->ttl() . "\n";
}

// Create a DNS record
$response = HetznerLaravel::dnsZones()->rrsets()->create('example.com', [
    'name' => 'www',
    'type' => 'A',
    'ttl' => 3600,
    'records' => [
        [
            'value' => '192.168.1.1',
            'comment' => 'Web server',
        ],
    ],
]);

$rrset = $response->rrset();
echo "Created record: " . $rrset->name() . " " . $rrset->type();

// Export zone file
$exportResponse = HetznerLaravel::dnsZones()->export('example.com');
echo "Zone file: " . $exportResponse->zoneFile();

// Change zone nameservers
$actionResponse = HetznerLaravel::dnsZones()->actions()->changeNameservers('example.com', [
    'nameservers' => ['ns1.example.com', 'ns2.example.com'],
]);
echo "Action status: " . $actionResponse->action()->status();
```

### Meta Information

[](#meta-information)

Access rate limits and request details:

```
$response = $client->servers()->list();
$meta = $response->meta();

echo "Request ID: " . $meta->requestId;
echo "Rate Limit: " . $meta->rateLimitLimit;
echo "Remaining: " . $meta->rateLimitRemaining;
echo "Reset Time: " . $meta->rateLimitReset;
```

Testing
-------

[](#testing)

The package provides a fake implementation for testing:

```
use Boci\HetznerLaravel\Testing\ClientFake;
use Boci\HetznerLaravel\Responses\Servers\CreateResponse;

$client = new ClientFake([
    CreateResponse::fake([
        'name' => 'test-server',
        'server_type' => 'cpx11',
    ]),
]);

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

expect($response->server()->name())->toBe('test-server');

// Assert that requests were sent
$client->assertSent(\Boci\HetznerLaravel\Resources\Servers::class, function (string $method, array $parameters): bool {
    return $method === 'create' && $parameters['name'] === 'test-server';
});
```

### Testing with Exceptions

[](#testing-with-exceptions)

```
use Boci\HetznerLaravel\Testing\ClientFake;
use Boci\HetznerLaravel\Exceptions\ErrorException;

$client = new ClientFake([
    new ErrorException([
        'message' => 'Server not found',
        'code' => 'server_not_found',
    ], 404)
]);

// This will throw the ErrorException
$client->servers()->retrieve('non-existent');
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom HTTP Client

[](#custom-http-client)

```
use Boci\HetznerLaravel\Client;
use GuzzleHttp\Client as GuzzleClient;

$client = Client::factory()
    ->withApiKey('your-api-token')
    ->withHttpClient(new GuzzleClient([
        'timeout' => 60,
        'verify' => false, // Only for development
    ]))
    ->make();
```

### Dependency Injection

[](#dependency-injection)

```
use Boci\HetznerLaravel\Client;

class ServerController
{
    public function __construct(
        private Client $hetznerClient
    ) {}

    public function createServer()
    {
        $response = $this->hetznerClient->servers()->create([
            'name' => 'my-server',
            'server_type' => 'cpx11',
            'image' => 'ubuntu-24.04',
            'location' => 'nbg1',
        ]);

        return response()->json($response->toArray());
    }
}
```

API Resources
-------------

[](#api-resources)

The package is organized into resources that correspond to Hetzner Cloud API endpoints:

- **Actions**: Get multiple actions, get an action
- **Billing**: Get all prices
- **Certificates**: List, create, get, update, delete certificates
- **DNS Zones**: List, create, get, update, delete DNS zones + actions + RRSets
- **Firewalls**: List, create, get, update, delete firewalls + actions
- **Floating IPs**: List, create, get, update, delete floating IPs + actions
- **Images**: List, get, update, delete images + actions
- **ISOs**: List, get ISOs
- **Load Balancers**: List, create, get, update, delete load balancers + actions
- **Load Balancer Types**: List, get load balancer types
- **Locations**: List, get locations
- **Networks**: List, create, get, update, delete networks + actions
- **Placement Groups**: List, create, get, update, delete placement groups
- **Primary IPs**: List, create, get, update, delete primary IPs + actions
- **Servers**: List, create, get, update, delete servers + actions
- **Server Types**: List, get server types
- **SSH Keys**: List, create, get, update, delete SSH keys
- **Volumes**: List, create, get, update, delete volumes + actions

Error Handling
--------------

[](#error-handling)

The package provides custom exceptions for better error handling:

```
use Boci\HetznerLaravel\Exceptions\ErrorException;
use Boci\HetznerLaravel\Exceptions\TransporterException;

try {
    $response = $client->servers()->create($parameters);
} catch (ErrorException $e) {
    // Handle API errors
    echo "API Error: " . $e->getMessage();
    echo "Error Code: " . $e->getCode();
} catch (TransporterException $e) {
    // Handle network/transport errors
    echo "Network Error: " . $e->getMessage();
}
```

Documentation
-------------

[](#documentation)

For more information about the Hetzner Cloud API, please refer to the following resources:

- [Hetzner Cloud API Documentation](https://docs.hetzner.cloud/)
- [Hetzner Cloud API Reference](https://docs.hetzner.cloud/reference/cloud)
- [Hetzner Laravel Integration Guide](https://hetzner-laravel-docs.balkan-oci.com)

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Amar Beka](https://github.com/amar8eka)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

---

Quick Reference
---------------

[](#quick-reference)

### 🚀 Actions

[](#-actions)

- `list()` - Get multiple actions
- `retrieve(string $actionId)` - Get an action

### 🔐 Security

[](#-security)

#### Certificates

[](#certificates)

- `list()` - List certificates
- `create(array $parameters)` - Create a certificate
- `retrieve(string $certificateId)` - Get a certificate
- `update(string $certificateId, array $parameters)` - Update a certificate
- `delete(string $certificateId)` - Delete a certificate

#### SSH Keys

[](#ssh-keys)

- `list()` - List SSH keys
- `create(array $parameters)` - Create an SSH key
- `retrieve(string $sshKeyId)` - Get an SSH key
- `update(string $sshKeyId, array $parameters)` - Update an SSH key
- `delete(string $sshKeyId)` - Delete an SSH key

### 🌐 DNS Zones

[](#-dns-zones)

- `list()` - List DNS zones
- `create(array $parameters)` - Create a DNS zone
- `retrieve(string $zoneIdOrName)` - Get a DNS zone
- `update(string $zoneIdOrName, array $parameters)` - Update a DNS zone
- `delete(string $zoneIdOrName)` - Delete a DNS zone
- `export(string $zoneIdOrName)` - Export zone file
- `import(array $parameters)` - Import zone file
- `actions()` - Access zone actions
- `rrsets()` - Access DNS records

### 📍 Locations

[](#-locations)

- `list()` - List locations
- `retrieve(string $locationId)` - Get a location

### 🔥 Firewalls

[](#-firewalls)

- `list()` - List firewalls
- `create(array $parameters)` - Create a firewall
- `retrieve(string $firewallId)` - Get a firewall
- `update(string $firewallId, array $parameters)` - Update a firewall
- `delete(string $firewallId)` - Delete a firewall
- `actions()` - Access firewall actions

### 🌐 Floating IPs

[](#-floating-ips)

- `list()` - List floating IPs
- `create(array $parameters)` - Create a floating IP
- `retrieve(string $floatingIpId)` - Get a floating IP
- `update(string $floatingIpId, array $parameters)` - Update a floating IP
- `delete(string $floatingIpId)` - Delete a floating IP
- `actions()` - Access floating IP actions

### 🖥️ Servers

[](#️-servers)

- `list()` - List servers
- `create(array $parameters)` - Create a server
- `retrieve(string $serverId)` - Get a server
- `update(string $serverId, array $parameters)` - Update a server
- `delete(string $serverId)` - Delete a server
- `metrics(string $serverId, array $parameters)` - Get server metrics
- `actions()` - Access server actions

### 🖼️ Images

[](#️-images)

- `list()` - List images
- `retrieve(string $imageId)` - Get an image
- `update(string $imageId, array $parameters)` - Update an image
- `delete(string $imageId)` - Delete an image
- `actions()` - Access image actions

### 💿 ISOs

[](#-isos)

- `list()` - List ISOs
- `retrieve(string $isoId)` - Get an ISO

### 📦 Placement Groups

[](#-placement-groups)

- `list()` - List placement groups
- `create(array $parameters)` - Create a placement group
- `retrieve(string $placementGroupId)` - Get a placement group
- `update(string $placementGroupId, array $parameters)` - Update a placement group
- `delete(string $placementGroupId)` - Delete a placement group

### 🔗 Primary IPs

[](#-primary-ips)

- `list()` - List primary IPs
- `create(array $parameters)` - Create a primary IP
- `retrieve(string $primaryIpId)` - Get a primary IP
- `update(string $primaryIpId, array $parameters)` - Update a primary IP
- `delete(string $primaryIpId)` - Delete a primary IP
- `actions()` - Access primary IP actions

### ⚙️ Server Types

[](#️-server-types)

- `list()` - List server types
- `retrieve(string $serverTypeId)` - Get a server type

### ⚖️ Load Balancers

[](#️-load-balancers)

- `list()` - List load balancers
- `create(array $parameters)` - Create a load balancer
- `retrieve(string $loadBalancerId)` - Get a load balancer
- `update(string $loadBalancerId, array $parameters)` - Update a load balancer
- `delete(string $loadBalancerId)` - Delete a load balancer
- `metrics(string $loadBalancerId, array $parameters)` - Get load balancer metrics
- `actions()` - Access load balancer actions

### ⚖️ Load Balancer Types

[](#️-load-balancer-types)

- `list()` - List load balancer types
- `retrieve(string $loadBalancerTypeId)` - Get a load balancer type

### 🌐 Networks

[](#-networks)

- `list()` - List networks
- `create(array $parameters)` - Create a network
- `retrieve(string $networkId)` - Get a network
- `update(string $networkId, array $parameters)` - Update a network
- `delete(string $networkId)` - Delete a network
- `actions()` - Access network actions

### 💰 Billing

[](#-billing)

- `listPricing()` - Get all prices

### 💾 Volumes

[](#-volumes)

- `list()` - List volumes
- `create(array $parameters)` - Create a volume
- `retrieve(string $volumeId)` - Get a volume
- `update(string $volumeId, array $parameters)` - Update a volume
- `delete(string $volumeId)` - Delete a volume
- `actions()` - Access volume actions

---

*This package provides complete coverage of the Hetzner Cloud API, ensuring you can manage all your cloud resources programmatically with ease.*

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance61

Regular maintenance activity

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

249d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/136569130?v=4)[Amar Beka](/maintainers/amar8eka)[@amar8eka](https://github.com/amar8eka)

---

Top Contributors

[![amar8eka](https://avatars.githubusercontent.com/u/136569130?v=4)](https://github.com/amar8eka "amar8eka (19 commits)")

---

Tags

api-client-phpbocihetzner-cloudhetzner-laravellaravelphp-sdksdklaravelsdkapi clienthetznerhetzner cloudbocihetzner-laravel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/boci-hetzner-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/boci-hetzner-laravel/health.svg)](https://phpackages.com/packages/boci-hetzner-laravel)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
