Skip to content

Commit e449901

Browse files
Cannonb4llclaude
andcommitted
Fix #83
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0e77f2b commit e449901

3 files changed

Lines changed: 70 additions & 35 deletions

File tree

README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ $ploi->servers(123)->opcache()->refresh();
128128

129129
Available methods for sites:
130130
```php
131-
//Create site
131+
// Create site
132132
$ploi->servers(123)->sites()->create(
133133
$domain,
134134
$webDirectory = '/public',
135-
$projectDirectory = '/',
136-
$systemUser = 'ploi',
137-
$systemUserPassword = null,
138-
$webserverTemplate = null,
139-
$projectType = null
135+
$projectRoot = null,
136+
$systemUser = null,
137+
$webserverTemplate = null, // integer, webserver template ID
138+
$projectType = null, // e.g. 'laravel', 'wordpress', 'nodejs', 'statamic', etc.
139+
$webhookUrl = null
140140
);
141141

142142
// List sites
@@ -160,6 +160,12 @@ $ploi->servers(123)->sites(123)->logs();
160160
// Set PHP version for site to use
161161
$ploi->servers(123)->sites(123)->phpVersion($phpVersion);
162162

163+
// Clone site to another server
164+
$ploi->servers(123)->sites(123)->clone($cloneToServerId, $domain = null);
165+
166+
// Reset file permissions
167+
$ploi->servers(123)->sites(123)->resetPermissions();
168+
163169
// Enable test domain on site
164170
$ploi->servers(123)->sites(123)->enableTestDomain();
165171
// Disable test domain on site
@@ -216,12 +222,17 @@ $ploi->servers(123)->databases(123)->duplicate($name, $user = null, $password =
216222
Available methods for database backups:
217223
```php
218224
// Create database backup
225+
// Server and database IDs are automatically passed from the chain
219226
$ploi->servers(123)->databases(123)->backups()->create(
220-
$interval,
221-
$type,
227+
$interval, // 0=nightly, or minutes: 10, 20, 30, 40, 50, 60, 120, 240, 480, 720, 1440
228+
$backupConfiguration, // ID of your backup configuration from your Ploi profile
229+
$databases = null, // array of database IDs, defaults to the chained database
222230
$table_exclusions = null,
223-
$locations = null,
224-
$path = null
231+
$locations = null, // for google-drive driver
232+
$path = null, // for local driver
233+
$keep_backup_amount = null,
234+
$custom_name = null,
235+
$password = null // password for ZIP archive
225236
);
226237

227238
// List database backups

src/Ploi/Resources/DatabaseBackup.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ public function __construct(Server $server, Database $database, ?int $id = null)
2323

2424
public function buildEndpoint(): self
2525
{
26-
$this->setEndpoint($this->getServer()->getEndpoint() . '/' . $this->getServer()->getId() . '/databases/' . $this->getDatabase()->getId() . '/backups');
26+
$this->setEndpoint('backups/database');
2727

2828
if ($this->getId()) {
2929
$this->setEndpoint($this->getEndpoint() . '/' . $this->getId());
3030
}
3131

32-
if ($this->getAction()) {
33-
$this->setEndpoint($this->getEndpoint() . '/' . $this->getAction());
34-
}
35-
3632
return $this;
3733
}
3834

@@ -42,44 +38,47 @@ public function get(?int $id = null): Response
4238
$this->setId($id);
4339
}
4440

45-
// Make sure the endpoint is built
4641
$this->buildEndpoint();
4742

48-
return (is_null($this->getId()))
43+
return (is_null($this->getId()))
4944
? $this->page()
50-
: $this->getPloi()->makeAPICall($this->getEndpoint());
45+
: $this->getPloi()->makeAPICall($this->getEndpoint());
5146
}
5247

5348
public function create(
5449
int $interval,
55-
string $type,
50+
int $backup_configuration,
51+
?array $databases = null,
5652
?string $table_exclusions = null,
5753
?string $locations = null,
58-
?string $path = null
59-
): Response
60-
{
61-
// Remove the id
54+
?string $path = null,
55+
?int $keep_backup_amount = null,
56+
?string $custom_name = null,
57+
?string $password = null
58+
): Response {
6259
$this->setId(null);
6360

64-
// Set the options
6561
$options = [
6662
'body' => json_encode([
63+
'backup_configuration' => $backup_configuration,
64+
'server' => $this->getServer()->getId(),
65+
'databases' => $databases ?? [$this->getDatabase()->getId()],
6766
'interval' => $interval,
68-
'type' => $type,
6967
'table_exclusions' => $table_exclusions,
7068
'locations' => $locations,
71-
'path' => $path
69+
'path' => $path,
70+
'keep_backup_amount' => $keep_backup_amount,
71+
'custom_name' => $custom_name,
72+
'password' => $password,
7273
]),
7374
];
7475

7576
$this->buildEndpoint();
7677

77-
// Make the request
7878
$response = $this->getPloi()->makeAPICall($this->getEndpoint(), 'post', $options);
7979

8080
$this->setId($response->getJson()->data->id);
8181

82-
// Return the response
8382
return $response;
8483
}
8584

src/Ploi/Resources/Site.php

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ public function buildEndpoint(): self
6868
public function create(
6969
string $domain,
7070
string $webDirectory = '/public',
71-
string $projectRoot = '/',
72-
string $systemUser = 'ploi',
73-
?string $systemUserPassword = null,
74-
?string $webserverTemplate = null,
75-
?string $projectType = null
71+
?string $projectRoot = null,
72+
?string $systemUser = null,
73+
?int $webserverTemplate = null,
74+
?string $projectType = null,
75+
?string $webhookUrl = null
7676
): Response {
7777

7878
// Remove the id
@@ -85,9 +85,9 @@ public function create(
8585
'web_directory' => $webDirectory,
8686
'project_root' => $projectRoot,
8787
'system_user' => $systemUser,
88-
'system_user_password' => $systemUserPassword,
8988
'webserver_template' => $webserverTemplate,
90-
'project_type' => $projectType
89+
'project_type' => $projectType,
90+
'webhook_url' => $webhookUrl,
9191
]),
9292
];
9393

@@ -246,6 +246,31 @@ public function horizonStatistics(string $type = 'stats'): Response
246246
return $this->getPloi()->makeAPICall($this->getEndpoint() . '/laravel/horizon/' . $type);
247247
}
248248

249+
public function clone(int $cloneToServer, ?string $domain = null): Response
250+
{
251+
$this->setIdOrFail();
252+
253+
$options = [
254+
'body' => json_encode([
255+
'clone_to_server' => $cloneToServer,
256+
'domain' => $domain,
257+
]),
258+
];
259+
260+
$this->buildEndpoint();
261+
262+
return $this->getPloi()->makeAPICall($this->getEndpoint() . '/clone', 'post', $options);
263+
}
264+
265+
public function resetPermissions(?int $id = null): Response
266+
{
267+
$this->setIdOrFail($id);
268+
269+
$this->buildEndpoint();
270+
271+
return $this->getPloi()->makeAPICall($this->getEndpoint() . '/permission-reset', 'post');
272+
}
273+
249274
public function redirects($id = null): Redirect
250275
{
251276
return new Redirect($this->getServer(), $this, $id);

0 commit comments

Comments
 (0)