PHP code example of gosuccess / php-enhance-api-wrapper
1. Go to this page and download the library: Download gosuccess/php-enhance-api-wrapper 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/ */
gosuccess / php-enhance-api-wrapper example snippets
use GoSuccess\Enhance\Enhance;
$enhance = Enhance::create(
host: 'https://cp.example.com/api',
orgId: 'your-organization-uuid',
accessToken: 'your-access-token',
);
// Read the API version
echo $enhance->install->orchdVersion();
// List the organization's plans (uses the configured organization id)
$plans = $enhance->plans->getPlans();
use GoSuccess\Enhance\DTO\NewWebsite;
use GoSuccess\Enhance\Enum\PhpVersion;
use GoSuccess\Enhance\Enum\WebsiteKind;
$website = new NewWebsite();
$website->domain = 'example.test';
$website->phpVersion = PhpVersion::Php84;
$created = $enhance->websites->createWebsite($website, WebsiteKind::Normal);
echo $created->id; // NewResourceUuid::$id
$update = new UpdateWebsite();
$update->setNull('phpVersion');
$enhance->websites->updateWebsite($update, $websiteId);
$enhance->websites->getWebsites(); // configured organization
$enhance->websites->getWebsites(orgId: 'other-org-uuid'); // another organization
use GoSuccess\Enhance\Util\Paginator;
foreach (Paginator::items(
fn (int $offset, int $limit) => $enhance->websites->getWebsites(offset: $offset, limit: $limit),
) as $website) {
echo $website->id . "\n";
}
use GoSuccess\Enhance\Enhance;
use GoSuccess\Enhance\Client\Configuration;
$config = new Configuration('https://cp.example.com/api', 'org-uuid', 'access-token');
$config->timeout = 60; // request timeout in seconds (default 30)
$config->maxRetries = 3; // retries for transient failures (default 2)
$config->verifySsl = true; // TLS verification (enabled by default)
$config->retryOnRateLimit = true; // false: a 429 throws at once instead of waiting
$enhance = new Enhance($config);
use GoSuccess\Enhance\Client\Configuration;
use GoSuccess\Enhance\Enum\HttpMethod;
use GoSuccess\Enhance\Http\RawResponse;
use GoSuccess\Enhance\Http\Transport;
final class MyTransport implements Transport
{
public function send(HttpMethod $method, string $url, array $headers, string|array|null $payload, Configuration $config): RawResponse
{
// $headers are complete lines ("Accept: application/json"); an array payload is a multipart form.
// Throw GoSuccess\Enhance\Exception\TransportException on connection errors and timeouts,
// return HTTP error statuses as a normal RawResponse, never follow redirects.
}
}
$enhance = new Enhance($config, transport: new MyTransport());
$enhance = new Enhance($config, $myHttpClient);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.