virtualine-net / php-client
Virtualine.net API Client
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/virtualine-net/php-client
Requires
- php: >=7.4
README
PHP client library for interacting with the Virtualine API. This library provides a simple and efficient way to manage virtual servers and services through the Virtualine platform.
Features
- Simple API authentication using API key and email
- Credit balance management
- Product listing and management
- Virtual server operations:
- Create new services
- Start/Stop/Reboot servers
- Change passwords
- Terminate services
- Suspend/Unsuspend services
- Reinstall templates
- Get WMSK URLs
- Service information and details retrieval
- Connection testing
Requirements
- PHP 7.4 or higher
- Composer
- Virtualine HTTP Client
Installation
You can install the library via Composer:
composer require virtualine-net/php-client
Usage
Basic Setup
use Virtualine\VirtualineClient; // Initialize the client with your API credentials $client = new VirtualineClient('your-api-key', 'your-email'); // Test the connection if ($client->testConnection()) { echo "Successfully connected to Virtualine API"; }
Creating a New Service
// Create a new service with detailed configuration $result = $client->createService($productId, [ 'cycle' => "monthly", 'hostname' => "service.virtualine.net", 'username' => "root", 'password' => "password", 'nsprefix[]' => 'ns1', 'nsprefix[]' => 'ns2', 'configurations[Operating System]' => 1 ]); if ($result) { echo "Service created successfully!"; } else { echo "Failed to create service."; }
Managing Services
// Get available products $products = $client->getProducts(); // Get service details $serviceDetails = $client->getServiceDetails('service-id'); // Manage service state $client->start('service-id'); $client->stop('service-id'); $client->reboot('service-id'); // Change service password $client->changePassword('service-id', 'new-password'); // Reinstall service $client->reinstall('service-id', 'template-id', 'new-password');
Billing and Credits
// Check credit balance $creditBalance = $client->getCredit();
API Methods
Authentication
__construct(string $apiKey, string $email)- Initialize the client with API credentials
Connection
testConnection(): bool- Test the API connection
Billing
getCredit(): float- Get current credit balance
Products
getProducts(): array- Get list of available products
Services
getServiceDetails(string $serviceId): array- Get detailed information about a servicegetInfo(string $serviceId): array- Get service informationcreateService(string $productId, array $params): array|false- Create a new servicestart(string $serviceId): array|false- Start a servicestop(string $serviceId): array|false- Stop a servicereboot(string $serviceId): array|false- Reboot a servicechangePassword(string $serviceId, string $password): array|false- Change service passwordterminate(string $serviceId): array|false- Terminate a servicesuspend(string $serviceId): array|false- Suspend a serviceunsuspend(string $serviceId): array|false- Unsuspend a servicerenew(string $serviceId): array|false- Renew a servicereinstallTemplates(string $serviceId): array- Get available reinstall templatesreinstall(string $serviceId, string $templateId, string $password): array|false- Reinstall a servicegetWMKSUrl(string $serviceId): string|false- Get WMSK URL for a servicessoLogin(string $serviceId): string|false- Get SSO login URL for a service
Error Handling
The client throws exceptions in case of errors:
InvalidArgumentException- When required parameters are missingRuntimeException- When API requests fail
Support
For support, please contact Virtualine support team or create an issue in the repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Authors
- Virtualine.net Team