1. Go to this page and download the library: Download porkbun-php/client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
porkbun-php / client example snippets
$client = new Porkbun\Client();
$client->authenticate('pk1_your_api_key', 'sk1_your_secret_key');
// Test connectivity
$ping = $client->ping();
echo "Your IP: {$ping->resolvedIp}";
// Domain pricing (no auth ns()->all() as $record) {
echo "{$record->name} {$record->type->value} {$record->content}\n";
}
// Get SSL certificate
$cert = $domain->ssl();
echo $cert->certificateChain;
// Custom PSR-18 HTTP client
$client = new Porkbun\Client($myPsr18Client);
// IPv4-only endpoint (useful for dynamic DNS)
$client->useIpv4Endpoint();
$client->useDefaultEndpoint(); // back to dual-stack
// Switch accounts at runtime
$client->authenticate($account2Key, $account2Secret);
$client->clearAuth(); // back to unauthenticated
$pricing = $client->pricing()->all();
$pricing->find('com')?->registrationPrice; // float
$pricing->find('com')?->renewalPrice; // float
$pricing->cheapest(10); // Top 10 cheapest TLDs
$pricing->tlds(); // All available TLD keys
$ping = $client->ping();
$ping->resolvedIp; // Your IP address (prefers forwarded IP)
$ping->forwardedIp; // Forwarded IP (from X-Forwarded-For header)
$ping->yourIp; // Raw IP from API response
// List all domains (iterates all pages automatically)
foreach ($client->domains()->all() as $domain) {
echo "{$domain->domain} expires {$domain->expireDate?->format('Y-m-d')}\n";
}
// Single page with pagination metadata
$page = $client->domains()->list();
$page->domains(); // DomainCollection (also available via iteration/count/json on $page itself)
$page->hasMore; // bool — true if more pages exist
$page->nextStart; // ?int — pass to list() for the next page
$page->start; // int — current offset
// PaginatedResult is iterable, countable, and JSON-serializable:
count($page); // number of domains on this page
json_encode($page); // serializes with pagination metadata
foreach ($page as $domain) { /* ... */ }
// Paginate manually
$page = $client->domains()->list(start: 0,