用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ploi/ploi-php-sdk --skill ploi-php-sdk-expert命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | Ploi PHP SDK Expert |
| description | Best practices for using the Ploi PHP SDK to interact with the Ploi.io server management API |
| compatible_agents | ["Claude Code","Cursor","Windsurf","GitHub Copilot"] |
| tags | ["php","laravel","ploi","server-management","api","sdk"] |
This skill covers the Ploi PHP SDK (ploi/ploi-php-sdk), a PHP wrapper around the Ploi.io server management REST API. It uses Guzzle HTTP under the hood and provides a fluent, chainable interface for managing servers, sites, databases, deployments, and more.
Scope: Initializing the SDK client, chaining resources, performing CRUD operations on all Ploi API resources, handling pagination, error handling, and understanding the resource hierarchy.
$ploi = new \Ploi\Ploi($apiToken);$ploi->setApiToken($token);https://ploi.io/api/ with JSON content headers.$ploi instance and drill down:
$ploi->server($serverId) to target a server$ploi->server($serverId)->sites($siteId) to target a site on a server$ploi->server($serverId)->sites($siteId)->certificates() to access certificates on a site$ploi->server() and $ploi->servers() both return a Server resource.$ploi->server($id)->): sites(), databases(), cronjobs(), daemons(), sshKeys(), services(), networkRules(), systemUsers(), opcache(), insights(), loadBalancer()->sites($id)->): certificates(), repository(), queues(), deployment(), app(), environment(), alias(), redirects(), fastCgi(), authUser(), robots(), tenants(), monitors(), nginxConfiguration()->databases($id)->): backups(), users()$ploi->): project(), scripts(), statusPage(), user(), webserverTemplates(), fileBackup()->get() to list all resources or fetch a single one by ID.->get() returns a Ploi\Http\Response object. Use ->getJson() for a stdClass, ->getData() for the data property, or ->toArray() for the full structure.->get($id), the ID parameter is optional if you already passed it during chaining.create() method with named parameters matching the API. Always check the method signature for required vs. optional parameters.HasPagination support ->page($pageNumber, $perPage) and ->perPage($amount).$ploi->server($id)->sites()->page(2, 15);Ploi\Exceptions\Http\Unauthenticated (401)Ploi\Exceptions\Http\NotFound (404)Ploi\Exceptions\Http\NotAllowed (405)Ploi\Exceptions\Http\NotValid (422)Ploi\Exceptions\Http\TooManyAttempts (429)Ploi\Exceptions\Http\InternalServerError (500)Ploi\Exceptions\Http\PerformingMaintenance (503)Ploi\Exceptions\Resource\RequiresId is thrown when a resource method needs an ID but none was provided.deployment() resource on a site: $ploi->server($id)->sites($siteId)->deployment()->deploy();->deployment()->deployScript() and ->deployment()->updateDeployScript($script).->repository()->toggleQuickDeploy().['body' => json_encode([...])] (Guzzle options format).get, post, patch, and delete HTTP methods are supported.use Ploi\Ploi;
$ploi = new Ploi('your-api-token');
$response = $ploi->servers()->page(1, 10);
$servers = $response->getData();
$server = $ploi->server(123)->get();
echo $server->getData()->name;
$response = $ploi->server(123)->sites()->create(
domain: 'example.com',
webDirectory: '/public',
projectRoot: '/',
systemUser: 'ploi'
);
$ploi->server(123)->sites(456)->repository()->install(
provider: 'github',
branch: 'main',
name: 'owner/repo'
);
$ploi->server(123)->sites(456)->deployment()->deploy();
// List certificates
$certs = $ploi->server(123)->sites(456)->certificates()->get();
// Create a Let's Encrypt certificate
$ploi->server(123)->sites(456)->certificates()->create(
certificate: 'example.com',
type: 'letsencrypt'
);
// Create a database
$ploi->server(123)->databases()->create(
name: 'my_app',
user: 'my_user',
password: 'secret'
);
// Set up automated backups
$ploi->server(123)->databases(789)->backups()->create(
interval: 1440,
type: 'to_server'
);
$ploi->server(123)->sites(456)->queues()->create(
connection: 'redis',
queue: 'default',
maximumSeconds: 60,
sleep: 30,
processes: 3,
maximumTries: 3
);
$ploi->server(123)->sites(456)->environment()->update(
content: "APP_ENV=production\nAPP_DEBUG=false\nAPP_KEY=base64:..."
);
use Ploi\Exceptions\Http\NotFound;
use Ploi\Exceptions\Http\NotValid;
use Ploi\Exceptions\Http\Unauthenticated;
try {
$server = $ploi->server(999)->get();
} catch (Unauthenticated $e) {
// Invalid API token
} catch (NotFound $e) {
// Server not found
} catch (NotValid $e) {
// Validation error - check the response body for details
}
// Create a daemon
$ploi->server(123)->daemons()->create(
command: 'php artisan horizon',
systemUser: 'ploi',
processes: 1,
directory: '/home/ploi/example.com'
);
// Restart a daemon
$ploi->server(123)->daemons(789)->restart();
$ploi->server(123)->cronjobs()->create(
command: 'php /home/ploi/example.com/artisan schedule:run',
frequency: '* * * * *',
user: 'ploi'
);
// Restart nginx
$ploi->server(123)->services('nginx')->restart();
// Restart MySQL
$ploi->server(123)->services('mysql')->restart();
// Bad - creating multiple instances
$servers = (new Ploi($token))->servers()->get();
$sites = (new Ploi($token))->server(1)->sites()->get();
// Good - reuse the client
$ploi = new Ploi($token);
$servers = $ploi->servers()->get();
$sites = $ploi->server(1)->sites()->get();
// Bad - constructing URLs by hand
$ploi->makeAPICall('servers/123/sites/456/certificates', 'get');
// Good - use the fluent chain
$ploi->server(123)->sites(456)->certificates()->get();
// Bad - catching generic exceptions
try {
$ploi->server(123)->get();
} catch (\Exception $e) {
echo "Something went wrong";
}
// Good - catch specific exceptions for proper handling
try {
$ploi->server(123)->get();
} catch (TooManyAttempts $e) {
sleep(60); // Wait and retry for rate limiting
} catch (NotFound $e) {
// Handle missing resource
} catch (Unauthenticated $e) {
// Handle invalid token
}
// Bad - redundant ID passing
$ploi->server(123)->sites(456)->certificates()->get(789);
// And then again:
$ploi->server(123)->sites(456)->certificates(789)->get(789);
// Good - pass the ID once, either in the chain or in the method
$ploi->server(123)->sites(456)->certificates(789)->get();
// or
$ploi->server(123)->sites(456)->certificates()->get(789);
// Bad - decoding manually
$response = $ploi->servers()->get();
$body = json_decode($response->getResponse()->getBody()->getContents());
// Good - use the Response helper methods
$response = $ploi->servers()->get();
$data = $response->getData(); // Parsed data property
$json = $response->getJson(); // Full parsed JSON
$array = $response->toArray(); // Array with json + response
基于 SOC 职业分类