1. Go to this page and download the library: Download akeeba/json-backup-api 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/ */
akeeba / json-backup-api example snippets
// Create an Options object which tells the library where and how to connect to the backup software
$options = new \Akeeba\BackupJsonApi\Options([
'capath' => \Composer\CaBundle\CaBundle::getBundledCaBundlePath(),
'ua' => 'MyFancyApp/1.2.3',
'host' => 'example.com',
'secret' => 'Sυρ3rC4l1Fr@gil15ti(E><pial!d0ciou5',
]);
// Create an HTTP client object. Here, we are using one that makes use of Guzzle 7 (you need to install Guzzle yourself)
$httpClient = new \Akeeba\BackupJsonApi\HttpAbstraction\HttpClientGuzzle($options);
// Get the API client itself.
$apiClient = new \Akeeba\BackupJsonApi\Connector($httpClient);
$backupOptions = new \Akeeba\BackupJsonApi\DataShape\BackupOptions([
'profile' => 5,
'description' => 'Remote backup using the API client',
'comment' => 'Look, mum! I can take backups without logging into the site!'
]);
$apiClient->backup($backupOptions, function ($data) {
echo "Received backup tick\n";
echo sprintf("Domain : %s\n", $data->Domain);
echo sprintf("Step : %s\n", $data->Step);
echo sprintf("Substep : %s\n", $data->Substep);
echo sprintf("Progress : %0.2f%%\n", $data->Progress);
if (!empty($data->Warnings))
{
echo "Warnings\n========\n";
foreach ($data->Warnings as $warning)
{
echo $warning . "\n";
}
}
if (!$data->HasRun && empty($data->Error))
{
echo "The backup finished successfully.\n";
}
elseif (!empty($data->Error))
{
echo "The backup finished with an error:\n{$data->Error}\n";
}
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.