aventure/dnsimple

There is no license information available for the latest version (v0.1.6) of this package.

DNSimple API v2 client library for PHP

v0.1.6 2017-06-21 06:59 UTC

README

PHP library for DNSimple api v2

Install

Via composer

composer require aventure/dnsimple

Usage

You need to create a new instance of HTTP client before use service.

$client = DNSimpleClient($account_token, $envronment);

$dns = DNSimpleService( $client );

// Default return type is "object".
echo (array) $dns->domains->all();
echo (array) $dns->domains->get([ 'name' => 'example.com' ]);
echo (array) $dns->domains->create([ 'name' => 'example.com' ]);
echo (array) $dns->domains->delete([ 'name' => 'example.com' ]);
echo (array) $dns->domains->resetToken([ 'name' => 'example.com' ]);
echo (array) $dns->domains->check([ 'name' => 'example.com' ]);

Laravel integration

Package contains a Laravel Service Provider yet to integrate library in a Laravel project using dependency injection

Add service provider to your config.php

Aventure\DNSimple\DNSimpleServiceProvider::class

Configuration

Publish configuration file

php artisan vendor:publish --provider:"Aventure\DNSimple\DNSimpleServiceProvider"

Add your account token in your .env file

DNSIMPLE_TOKEN=********************

Inject service in your Controller


class DNSimpleController extends Controller
{
    /**
     * Service instance
     *
     * @var DNSimpleService
     */
    public $dns;

    /**
     * DNSimpleController constructor.
     * 
     * @param DNSimpleService $dns
     */
    public function __construct(DNSimpleService $dns)
    {
        $this->dns = $dns;
    }

    /**
     * Grab all records
     * 
     * @return array
     */
    public function all()
    {
        return (array) $this->dns->domains->all();
    }

    /**
     * Domain details
     * 
     * @param string $name
     * @return array
     */
    public function get($name)
    {
        return (array) $this->dns->domains->get(['name' => $name]);
    }
}