libvirt-php: PHP API Reference guide
Description: libvirt, virtualization, virtualization API

# PHP API Reference guide

### Functions

    Total number of functions: 8. Functions supported are:

    	libvirt_get_last_error()

    	libvirt_image_create($conn, $name, $size, $format)

    	libvirt_image_remove($conn, $image)

    	libvirt_version($type)

    	libvirt_check_version($major, $minor, $micro, $type)

    	libvirt_has_feature($name)

    	libvirt_get_iso_images($path)

    	libvirt_print_binding_resources()

    	libvirt_logfile_set($filename, $maxsize)

### `libvirt_get_last_error`

    libvirt_get_last_error()

[Since version 0.4.1(-1)]

This function is used to get the last error coming either from libvirt or the PHP extension itself.

`Returns`: | : last error string

### `libvirt_image_create`

    libvirt_image_create($conn, $name, $size, $format)

[Since version 0.4.2]

Function is used to create the image of desired name, size and format. The image will be created in the image path (libvirt.image_path INI variable). Works only o.

`@conn [resource]`: | libvirt connection resource
`@name [string]`: | name of the image file that will be created in the libvirt.image_path directory
`@size [int]`: | size of the image in MiBs
`@format [string]`: | format of the image, may be raw, qcow or qcow2
`Returns`: | : hostname of the host node or FALSE for error

### `libvirt_image_remove`

    libvirt_image_remove($conn, $image)

[Since version 0.4.2]

Function is used to create the image of desired name, size and format. The image will be created in the image path (libvirt.image_path INI variable). Works only on local systems!.

`@conn [resource]`: | libvirt connection resource
`@image [string]`: | name of the image file that should be deleted
`Returns`: | : hostname of the host node or FALSE for error

### `libvirt_version`

    libvirt_version($type)

[Since version 0.4.1(-1)]

Function is used to get libvirt, driver and libvirt-php version numbers. Can be used for information purposes, for version checking please use libvirt_check_version() defined below.

`@type [string]`: | optional type string to identify driver to look at
`Returns`: | : libvirt, type (driver) and connector (libvirt-php) version numbers array

### `libvirt_check_version`

    libvirt_check_version($major, $minor, $micro, $type)

[Since version 0.4.1(-1)]

Function is used to check major, minor and micro (also sometimes called release) versions of libvirt-php or libvirt itself. This could useful when you want your application to support only versions of libvirt or libvirt-php higher than some version specified..

`@major [long]`: | major version number to check for
`@minor [long]`: | minor version number to check for
`@micro [long]`: | micro (also release) version number to check for
`@type [long]`: | type of checking, VIR_VERSION_BINDING to check against libvirt-php binding or VIR_VERSION_LIBVIRT to check against libvirt version
`Returns`: | : TRUE if version is equal or higher than required, FALSE if not, FALSE with error [for libvirt_get_last_error()] on unsupported version type check

### `libvirt_has_feature`

    libvirt_has_feature($name)

[Since version 0.4.1(-3)]

Function to check for feature existence for working libvirt instance.

`@name [string]`: | feature name
`Returns`: | : TRUE if feature is supported, FALSE otherwise

### `libvirt_get_iso_images`

    libvirt_get_iso_images($path)

[Since version 0.4.1(-3)]

Function to get the ISO images on path and return them in the array.

`@path [string]`: | string of path where to look for the ISO images
`Returns`: | : ISO image array on success, FALSE otherwise

### `libvirt_print_binding_resources`

    libvirt_print_binding_resources()

[Since version 0.4.2]

Function to print the binding resources, although the resource information are printed, they are returned in the return_value.

`Returns`: | : bindings resource information

### `libvirt_logfile_set`

    libvirt_logfile_set($filename, $maxsize)

[Since version 0.4.2]

Function to set the log file for the libvirt module instance.

`@filename [string]`: | log filename or NULL to disable logging
`@maxsize [long]`: | optional maximum log file size argument in KiB, default value can be found in PHPInfo() output
`Returns`: | : TRUE if log file has been successfully set, FALSE otherwise