Skip to content

Commit 6d9ce13

Browse files
Cannonb4llclaude
andcommitted
Add installPhpVersion() and switchPhpCliVersion() to Server (#68)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 578815a commit 6d9ce13

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ $ploi->servers(123)->monitoring();
114114
// Get PHP versions installed on server
115115
$ploi->servers(123)->phpVersions();
116116

117+
// Install a PHP version on server
118+
$ploi->servers(123)->installPhpVersion('8.3');
119+
120+
// Switch PHP CLI version on server
121+
$ploi->servers(123)->switchPhpCliVersion('8.3');
122+
117123
// Enable opcache
118124
$ploi->servers(123)->opcache()->enable();
119125

src/Ploi/Resources/Server.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,32 @@ public function phpVersions(?int $id = null): Response
183183
return $this->callApi('php/versions');
184184
}
185185

186+
public function installPhpVersion(string $version): Response
187+
{
188+
$this->setIdOrFail();
189+
190+
$options = [
191+
'body' => json_encode([
192+
'version' => $version,
193+
]),
194+
];
195+
196+
return $this->callApi('php/install', 'post', $options);
197+
}
198+
199+
public function switchPhpCliVersion(string $version): Response
200+
{
201+
$this->setIdOrFail();
202+
203+
$options = [
204+
'body' => json_encode([
205+
'version' => $version,
206+
]),
207+
];
208+
209+
return $this->callApi('php/cli-version', 'post', $options);
210+
}
211+
186212
public function restart(?int $id = null): Response
187213
{
188214
$this->setIdOrFail($id);

0 commit comments

Comments
 (0)