PHPackages                             kasuganosoras/libvirt-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kasuganosoras/libvirt-manager

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kasuganosoras/libvirt-manager
=============================

A library to control the libvirt virtual machine.

632419[1 issues](https://github.com/kasuganosoras/Libvirt-Manager/issues)PHP

Since Jun 3Pushed 6y ago3 watchersCompare

[ Source](https://github.com/kasuganosoras/Libvirt-Manager)[ Packagist](https://packagist.org/packages/kasuganosoras/libvirt-manager)[ RSS](/packages/kasuganosoras-libvirt-manager/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Libvirt-Manager
===============

[](#libvirt-manager)

[中文 ReadMe](README_ZH.md) | [ZeroDream](https://www.zerodream.net/)

This is a simple php libvirt manager

It can start, shutdown, destory, get the virtual machines list or get the information for any virtual machine.

This project is to make it easier for developers to manage virtual machines.

You need install php\_ssh2 module to use this manager.

Maybe this document has some grammatical mistakes, because the author is Chinese :P

### Install Libvirt-Manager

[](#install-libvirt-manager)

Use composer

```
composer require kasuganosoras/libvirt-manager

```

Use git

```
git clone https://github.com/kasuganosoras/Libvirt-Manager

```

### Example code for connect a server

[](#example-code-for-connect-a-server)

This example code will connect to your server using SSH, make sure your server sshd service is running.

```
require_once __DIR__ . '/vendor/autoload.php';
use libvirt_manager\Libvirt;
$Libvirt = new Libvirt();
$Libvirt->setHost("192.168.3.181", 22, "/data/libvirt/");
$Libvirt->connect("root", "123456");
```

The `192.168.3.181` is your server hostname, `22` is your server port, and `/data/libvirt/` is your libvirt data save path.

For authenticate, use username and password, the username and password in example code is `root` and `123456`.

### Example code for create a virtual machine

[](#example-code-for-create-a-virtual-machine)

The following example code will create a virtual machine called Test and allocate 2 CPU cores, 2 GB of memory to it.

```
$Libvirt->createDisk("Test", "qcow2", "30G");
$Libvirt->createVMXML("Test", 2, 2048576, "/data/libvirt/images/Test/Test.qcow2", "/data/iso/CentOS-7-x86_64-Minimal-1804.iso", "cdrom", "network", "default", $Libvirt->randomMac(), "virbr0", 0, 0, 5902);
$Libvirt->define("/data/libvirt/Test.xml");
$Libvirt->setPermission("Test");
$Libvirt->start("Test");
```

#### Create a virtual disk

[](#create-a-virtual-disk)

```
String createDisk ( Name, Format, Size )
```

#### create a Virtual Machine xml config file

[](#create-a-virtual-machine-xml-config-file)

The method of createVMXML have 13 params.

```
void createVMXL ( Name, vCPU, Ram, Disk, ISO, Boot Device, Network type, Network name, MAC Address, Network bridge, Bandwidth in, Bandwidth out, VNC Port )
```

#### Register the xml config file to system

[](#register-the-xml-config-file-to-system)

```
String define ( XML File Path )
```

#### Set execute permission

[](#set-execute-permission)

```
void setPermission ( Name )
```

#### Start the virtual machine

[](#start-the-virtual-machine)

```
String start ( Name )
```

#### Stop the virtual machine

[](#stop-the-virtual-machine)

```
String shutdown ( Name )
```

#### Force stop the virtual machine

[](#force-stop-the-virtual-machine)

if your virtual machine is in trouble and can't use shutdown to make if off, you can use this method to force stop it.

```
String destroy ( Name )
```

#### Get the virtual machine list

[](#get-the-virtual-machine-list)

You can use this method to get the virtual machine list, It will return an array.

```
String getList ()
```

#### Get the virtual machine information

[](#get-the-virtual-machine-information)

You can use this method to get any registed virtual machine information, It will return an array.

```
String getInfo ( Name )
```

#### Dump the virtual machine xml config file

[](#dump-the-virtual-machine-xml-config-file)

This method can get any registered virtual machine xml config file and return.

```
String dumpxml ( Name )
```

#### Clone an exist virtual machine

[](#clone-an-exist-virtual-machine)

You can use this method to clone a exist virtual machine.

This method may take a long time, you need add a line `set_time_limit(120)` in your code.

```
String cloneVM ( Name, New name, New disk path )
```

#### Set the virtual machine network

[](#set-the-virtual-machine-network)

This method can control the virtual machine network.

The third param is Boolean type, if you give it a true value, the network will enable, else the network will disable.

```
String setNetwork ( Server, Network name, Status )
```

You can find out more info in `libvirt/libvirt.php`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ac1f6526e2685e7b1c1cda4109347597d34c5a09e670104db2646fa873412a55?d=identicon)[Akkariin](/maintainers/Akkariin)

---

Top Contributors

[![kasuganosoras](https://avatars.githubusercontent.com/u/34357771?v=4)](https://github.com/kasuganosoras "kasuganosoras (20 commits)")

### Embed Badge

![Health badge](/badges/kasuganosoras-libvirt-manager/health.svg)

```
[![Health](https://phpackages.com/badges/kasuganosoras-libvirt-manager/health.svg)](https://phpackages.com/packages/kasuganosoras-libvirt-manager)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
