cylab-be/php-vbox-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cylab-be/php-vbox-api

Composer 安装命令:

composer require cylab-be/php-vbox-api

包简介

A PHP library to drive VirtualBox

README 文档

README

pipeline status coverage report

A PHP library to drive VirtualBox. The API allows you to do stuff like:

$vbox = new VBox($username, $password);

// a single .ova may contain multiple machines
$vms = $vbox->import("/path/to/image.ova");
$vm = $vms[0];

$vm->setMemorySize(512); // MB
$vm->setCPUCount(2);

$adapter = $vm->getNetworkAdapter(0);
$adapter->setAttachmentType(NetworkAdapter::ATTACHEMENT_BRIDGED);
$adapter->setBridgedInterface("eno1");

$vm->up();

This library is actually a wrapper for the SOAP webservice of VirtualBox. You can find a copy of the complete SOAP webservice documentation in the documentation directory.

Installation

The library itself is best installed using composer:

composer require cylab-be/php-vbox-api

VirtualBox Web Service

You of course have to download and install VirtualBox.

In VirtualBox, each virtual machine is a separate user process. So it is usually best to create a dedicated user for running your VM's :

sudo adduser vbox

Then add this new user to the vbox group so it will be allowed to run virtual machines :

sudo adduser vbox vbox

Finally, you have to activate the VirtualBox Web Service.

Therefore, you have to create the file /etc/default/virtualbox and indicate which user should be used to run your machines:

VBOXWEB_USER=vbox

You can now start the VirtualBox Web Service:

sudo service vboxweb-service restart

Usage

Connecting to VirtualBox

$vbox = new VBox("vbox", "passord-of-vbox-user");

List all machines

$vms = $vbox->allVMs();
foreach ($vms as $vm) {
  echo $vm->getName() . "\n";
  echo $vm->getUUID() . "\n";
}

Modify a VM

$vm = $vbox->findVM("name or UUID");

// do a clean shutdown
$vm->halt();
$vm->setMemory(2048);
$vm->setCPUCount(4);
$vm->up();

// do a hard shutdown
$vm->kill();

// destroy the VM
$vm->destroy();

Take a screenshot

$vm->up();
sleep(5);
$img = $vm->takeScreenshot();
file_put_contents('/path/to/screenshot.png', $img);

cylab-be/php-vbox-api 适用场景与选型建议

cylab-be/php-vbox-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.28k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cylab-be/php-vbox-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cylab-be/php-vbox-api 我们能提供哪些服务?
定制开发 / 二次开发

基于 cylab-be/php-vbox-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-12