libguestfs PHP bindings

An early upstream patch is available here. It needs a great deal more testing, but it is able to add drives and launch the appliance.

<?php

$g = guestfs_create ();
if ($g == false) {
  echo ("Failed to create guestfs_php handle.\n");
  exit;
}
if (guestfs_add_drive ($g, "/dev/null") == false) {
  echo ("Error: ".guestfs_last_error ($g)."\n");
  exit;
}
if (guestfs_launch ($g) == false) {
  echo ("Error: ".guestfs_last_error ($g)."\n");
  exit;
}
$version = guestfs_version ($g);
if ($version == false) {
  echo ("Error: ".guestfs_last_error ($g)."\n");
  exit;
}
var_dump($version);

?>
array(4) {
  ["major"]=>
  int(1)
  ["minor"]=>
  int(5)
  ["release"]=>
  int(7)
  ["extra"]=>
  string(0) ""
}

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s