vanguardbackup/vanguard-php-sdk
最新稳定版本:0.2.7
Composer 安装命令:
composer require vanguardbackup/vanguard-php-sdk
包简介
The official Vanguard PHP SDK.
README 文档
README
Vanguard PHP SDK
Overview
The Vanguard PHP SDK provides a fluent interface for interacting with Vanguard's API, enabling efficient management of your backup operations.
API Documentation
For comprehensive API documentation, including request/response schemas and example payloads, please refer to our official API documentation:
This resource is invaluable when constructing requests or handling responses, especially for complex operations not fully abstracted by the SDK.
Getting Started
Installation
Add the Vanguard PHP SDK to your project using Composer:
composer require vanguardbackup/vanguard-php-sdk
Initializing the SDK
Create a new instance of the VanguardBackup client:
$vanguard = new VanguardBackup\Vanguard\VanguardClient('YOUR_API_KEY');
For custom Vanguard installations, specify the API base URL:
$vanguard = new VanguardBackup\Vanguard\VanguardClient('YOUR_API_KEY', 'https://your-vanguard-instance.com');
Core Functionalities
User Authentication
Retrieve the authenticated user's information:
$user = $vanguard->user();
Backup Task Management
Manage your backup tasks:
// List all backup tasks $tasks = $vanguard->backupTasks(); // Get a specific backup task $task = $vanguard->backupTask($taskId); // Create a new backup task $newTask = $vanguard->createBackupTask([ 'label' => 'Daily Database Backup', 'source_type' => 'database', // ... other task parameters ]); // Update an existing backup task $updatedTask = $vanguard->updateBackupTask($taskId, [ 'frequency' => 'daily', // ... other parameters to update ]); // Delete a backup task $vanguard->deleteBackupTask($taskId); // Get the status of a backup task $status = $vanguard->getBackupTaskStatus($taskId); // Retrieve the latest log for a backup task $log = $vanguard->getLatestBackupTaskLog($taskId); // Manually trigger a backup task $vanguard->runBackupTask($taskId);
Individual BackupTask instances also provide methods for common operations:
$task->update(['label' => 'Weekly Full Backup']); $task->delete(); $task->getStatus(); $task->getLatestLog(); $task->run();
Backup Task Log Management
Manage logs for your backup tasks:
// List all backup task logs $logs = $vanguard->backupTaskLogs(); // Get a specific backup task log $log = $vanguard->backupTaskLog($logId); // Delete a backup task log $vanguard->deleteBackupTaskLog($logId);
Individual BackupTaskLog instances also provide methods for common operations:
$log->delete(); $log->isSuccessful(); $log->isFailed();
Remote Server Management
Manage the servers from which you're backing up data:
// List all remote servers $servers = $vanguard->remoteServers(); // Get a specific remote server $server = $vanguard->remoteServer($serverId); // Add a new remote server $newServer = $vanguard->createRemoteServer([ 'label' => 'Production DB Server', 'ip_address' => '192.168.1.100', // ... other server details ]); // Update a remote server $updatedServer = $vanguard->updateRemoteServer($serverId, [ 'label' => 'Updated Production DB Server', ]); // Remove a remote server $vanguard->deleteRemoteServer($serverId);
Backup Destination Management
Control where your backups are stored:
// List all backup destinations $destinations = $vanguard->backupDestinations(); // Get a specific backup destination $destination = $vanguard->backupDestination($destinationId); // Create a new backup destination $newDestination = $vanguard->createBackupDestination([ 'type' => 's3', 'bucket' => 'my-backups', // ... other destination details ]); // Update a backup destination $updatedDestination = $vanguard->updateBackupDestination($destinationId, [ 'bucket' => 'new-backup-bucket', ]); // Remove a backup destination $vanguard->deleteBackupDestination($destinationId);
Tag Management
Organize your backup resources with tags:
// List all tags $tags = $vanguard->tags(); // Get a specific tag $tag = $vanguard->tag($tagId); // Create a new tag $newTag = $vanguard->createTag(['label' => 'Production']); // Update a tag $updatedTag = $vanguard->updateTag($tagId, ['label' => 'Staging']); // Delete a tag $vanguard->deleteTag($tagId);
Notification Stream Management
Configure how you receive alerts about your backups:
// List all notification streams $streams = $vanguard->notificationStreams(); // Get a specific notification stream $stream = $vanguard->notificationStream($streamId); // Create a new notification stream $newStream = $vanguard->createNotificationStream([ 'type' => 'slack', 'webhook_url' => 'https://hooks.slack.com/services/...', ]); // Update a notification stream $updatedStream = $vanguard->updateNotificationStream($streamId, [ 'events' => ['backup_failed', 'backup_successful'], ]); // Delete a notification stream $vanguard->deleteNotificationStream($streamId);
SSH Key Management
Retrieve the Vanguard instance SSH public key:
// Get the instance SSH public key $sshKey = $vanguard->getInstanceSshKey(); // Access the public key as a string echo $sshKey->publicKey; // Or cast the object to a string to get the public key echo (string) $sshKey;
Security
For reporting security vulnerabilities, please refer to our security policy.
License
The Vanguard PHP SDK is open-source software, released under the MIT licence.
Acknowledgments
We'd like to express our gratitude to the Laravel Forge PHP SDK, which served as an inspiration for the structure and design of this SDK.
vanguardbackup/vanguard-php-sdk 适用场景与选型建议
vanguardbackup/vanguard-php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 08 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「sdk」 「backup」 「vanguard」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vanguardbackup/vanguard-php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vanguardbackup/vanguard-php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vanguardbackup/vanguard-php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
A simple database backup manager for Symfony2 with support for S3, Rackspace, Dropbox, FTP, SFTP.
Fix failed Craft backups and restores with full paths to psql, mysql, and mysqldump executables.
Alfabank REST API integration
Firebase Realtime database library to backup and restore small and larger projects.
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-09