Skip to content

DutchCodingCompany/laravel-hetzner-dns-api

Repository files navigation

An unofficial PHP SDK for the Hetzner DNS API.

Latest Version on Packagist Total Downloads

This PHP/Laravel client around the Hetzner DNS API support:

  • Zones
  • Records

This SDK is based on Saloon, a Laravel / PHP package that helps write API integrations and SDKs.

Installation

You can install the package via composer:

composer require dutchcodingcompany/laravel-hetzner-dns-api

Set your hetzner dns api token in your .env file:

HETZNER_DNS_API_TOKEN=hetzner-dns-token-here

Configuration (optional)

You can publish the config file with:

php artisan vendor:publish --tag="hetzner-dns-api-config"

This is the contents of the published config file can be found here.

If you would like to store the API Token outside of the config (e.g. encrypted in the database), you can override the resolver in the boot method of the AppServiceProvider

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use DutchCodingCompany\HetznerDnsClient\HetznerDnsClient;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        HetznerDnsClient::resolveApiTokenUsing(fn () => 'your-token');
    }
}

Usage

$records = HetznerDnsClient::records()->all();
// resolves to a Records DTO

ToDo

  • add caching
  • ...

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.