dyninc/dyn-php
PHP SDK for Dyn APIs. Manage DNS with Traffic Management (sessions, zones, records, redirects, dynamic DNS) and send email via Message Management. Supports PHP 7.4+, works with Composer, and includes examples and PHPUnit tests.
This SDK allows PHP developers to interact with Dyn's product APIs from within their PHP applications. Feedback is welcome - please reach out via pull request, GitHub issue, or via. our Community forum.
Requires PHP 7.4 or above. The cURL extension is recommended (although not required), and will be used if present.
The best way to install this SDK is with Composer. With Composer installed, run:
composer require dyninc/dyn-php
from the command line.
use Dyn\TrafficManagement;
use Dyn\TrafficManagement\Record\A;
$tm = new TrafficManagement('customerName', 'username', 'password');
// login
$tm->createSession();
// retrieve zone
$zone = $tm->getZone('example.com');
// configure a new record
$record = new A();
$record->setAddress('127.0.0.1');
// create the new record
$zone->createRecord($record, 'test.example.com');
// publish zone changes
$zone->publish();
// logout
$tm->deleteSession();
use Dyn\MessageManagement;
use Dyn\MessageManagement\Mail;
$mm = new MessageManagement('YOUR API KEY');
// setup the message
$mail = new Mail();
$mail->setFrom('user@example.com', 'Joe Bloggs')
->setTo('janedoe@example.com')
->setSubject('Email sent via. Dyn SDK')
->setBody('The text of the email');
// send it
$mm->send($mail);
More detailed examples can be found in the examples folder.
With the Composer packages installed, unit tests can be run from this folder using the command:
./vendor/bin/phpunit --configuration test/phpunit.xml
How can I help you explore Laravel packages today?