diff options
author | Richard Jones <rjones@redhat.com> | 2010-09-03 12:15:00 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2010-09-04 13:38:03 +0100 |
commit | 2c61e04c4599536fee771431fb1ebc8384523b2a (patch) | |
tree | 4d09707b244ba16df45e3ee4a1a8e7d80546ae5f /php/README-PHP | |
parent | 2d8fd7dacd77361bc385be42112289faafb5c60d (diff) | |
download | libguestfs-2c61e04c4599536fee771431fb1ebc8384523b2a.tar.gz libguestfs-2c61e04c4599536fee771431fb1ebc8384523b2a.tar.xz libguestfs-2c61e04c4599536fee771431fb1ebc8384523b2a.zip |
PHP bindings.
Note that these are not complete on 32 bit architectures. PHP doesn't
offer any convenient 64 bit type (on 32 bit). Therefore you should
always use these PHP bindings on 64 bit.
Diffstat (limited to 'php/README-PHP')
-rw-r--r-- | php/README-PHP | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/php/README-PHP b/php/README-PHP new file mode 100644 index 00000000..b5ad3c3a --- /dev/null +++ b/php/README-PHP @@ -0,0 +1,54 @@ +NOTE: The PHP API is not complete on 32 bit architectures. PHP +doesn't offer any convenient 64 bit type (on 32 bit). Any 64 bit +parameters or return values will be truncated to 32 bits on these +platforms. You should always use these PHP bindings on a 64 bit +operating system. + +To install the extension manually, copy guestfs_php.so into the +modules directory (eg. /usr/local/lib/php/modules/) and copy +guestfs_php.ini into the config directory (eg. /etc/php.d/). +[Note: On packaged Linux distributions you don't need to do this] + +The PHP API follows the C API. Refer to guestfs(3) or +http://libguestfs.org/guestfs.3.html for the details of the C API. + +To create a handle, use guestfs_create() like this: + + <?php + $g = guestfs_create (); + if ($g == false) { + echo ("Failed to create guestfs_php handle.\n"); + exit; + } + ?> + +Handles are closed implicitly by the PHP dtor. + +All of the usual functions from the C API are available. By +convention these return 'false' for errors, so: + + <?php + //... + if (guestfs_launch ($g) == false) { + echo ("Error: ".guestfs_last_error ($g)."\n"); + exit; + } + ?> + +or: + + <?php + //... + $version = guestfs_version ($g); + if ($version == false) { + echo ("Error: ".guestfs_last_error ($g)."\n"); + exit; + } + echo ("libguestfs version = ". + $version["major"].".".$version["minor"].".".$version["release"]. + $version["extra"]."\n"); + ?> + +C API structs are mapped to associative arrays. C API lists of +structs are mapped to arrays of associative arrays. Other C API +parameters and return values are mapped to natural PHP types. |