Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > f31dc99d1fcbc14f21aac707a6e28fcd > files > 16

php-libvirt-0.4.1-2.mga1.i586.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
        This file is autogenerated from examples.html.in
        Do not edit this file. Changes will be lost.
      -->
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="main.css" />
    <link rel="SHORTCUT ICON" href="graphics/32favicon.png" />
    <title>libvirt-php: Examples</title>
    <meta name="description" content="libvirt, virtualization, virtualization API" />
  </head>
  <body>
    <div id="header">
      <div id="headerLogo"></div>
      <div id="headerSearch">
        <form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><div>
            <input id="query" name="query" type="text" size="12" value="" />
            <input id="submit" name="submit" type="submit" value="Search" />
          </div></form>
      </div>
    </div>
    <div id="body">
      <div id="menu">
        <ul class="l0"><li>
            <div>
              <a title="Front page of the libvirt-php website" class="inactive" href="index.html">Home</a>
            </div>
          </li><li>
            <div>
              <a title="Details of new features and bugs fixed in each release" class="inactive" href="news.html">News</a>
            </div>
          </li><li>
            <div>
              <a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
            </div>
          </li><li>
            <div>
              <a title="Information on libvirt-php Windows port" class="inactive" href="windows.html">Windows port</a>
            </div>
          </li><li>
            <div>
              <a title="Information on contributing to libvirt-php" class="inactive" href="contributions.html">Contributions</a>
            </div>
          </li><li>
            <div>
              <a title="Information for users, administrators and developers" class="active" href="docs.html">Documentation</a>
              <ul class="l1"><li>
                  <div>
                    <a title="API reference documentation" class="inactive" href="api-reference.html">PHP API Reference</a>
                  </div>
                </li><li>
                  <div>
                    <a title="libvirt-php developer's API reference (private functions)" class="inactive" href="dev-api-reference.html">Developer's API Reference</a>
                  </div>
                </li><li>
                  <div>
                    <a title="How to compile libvirt-php" class="inactive" href="compiling.html">Compiling</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Information about deploying and using libvirt-php" class="inactive" href="deployment.html">Deployment</a>
                  </div>
                </li><li>
                  <div>
                    <span class="active">Examples</span>
                  </div>
                </li></ul>
            </div>
          </li><li>
            <div>
              <a title="List of companies and people using the project" class="inactive" href="references.html">References</a>
            </div>
          </li><li>
            <div>
              <a title="How to contact the developers via email and IRC" class="inactive" href="contact.html">Contact</a>
            </div>
          </li><li>
            <div>
              <a title="List of links related to libvirt-php project" class="inactive" href="links.html">Related links</a>
            </div>
          </li><li>
            <div>
              <a title="List of features to be implemented" class="inactive" href="roadmap.html">Roadmap</a>
            </div>
          </li><li>
            <div>
              <a title="Libvirt-php site map" class="inactive" href="sitemap.html">Sitemap</a>
            </div>
          </li></ul>
      </div>
      <div id="content">
        <h1>Examples</h1>
        <ul><li>
            <a href="#get-version">Getting libvirt, hypervisor and libvirt-php version</a>
          </li><li>
            <a href="#connecting">Connecting to libvirt daemon</a>
          </li><li>
            <a href="#listing-domains">Getting list of domains</a>
          </li></ul>
        <h2>
          <a name="get-version" id="get-version">Getting libvirt, hypervisor and libvirt-php version</a>
        </h2>
        <p>If you just want to check whether the module is working fine you can try to ask libvirt for
     libvirt/hypervisor version and libvirt-php version. Libvirt-php version is also available in
     phpinfo() output when a module is loaded. In your PHP script you can do it using following
     syntax:</p>
        <pre>&lt;?php
     $conn = libvirt_version();
?&gt;</pre>
        <p>The <i>var</i> variable will be having information about major, minor and release versions
      of the hypervisor and libvirt available and also there will be version number of libvirt-php
      connector in form of <i>major.minor.release</i>.</p>
        <h2>
          <a name="connecting" id="connecting">Connecting to libvirt daemon</a>
        </h2>
        <p>
       For connecting to libvirt daemon the <i>libvirt_connect()</i> API function has been introduced.
       This function accepts 2 arguments:</p>
        <ul><li>Hypevisor URI: string</li><li>Readonly: boolean</li></ul>
        <p>Hypervisor URI could be also string <i>null</i> to make libvirt probe the hypervisor driver
        that is applicable to the host machine.</p>
        <pre>&lt;?php
     $conn = libvirt_connect('null', false);
?&gt;</pre>
        <h2>
          <a name="listing-domains" id="listing-domains">Getting list of domains</a>
        </h2>
        <p>
       If you want to get the list of domains you can use <i>libvirt_list_domains()</i> API function.
       This function returns an array of libvirt domain resources that could be used with the
       <i>libvirt_domain_get_name()</i> API function to get the list of domain names like:</p>
        <pre>&lt;?php
     $conn = libvirt_connect('null', false);
     $doms = libvirt_list_domains($conn);
     $domNames = array();
     foreach ($doms as $dom)
         $domNames[] = libvirt_domain_get_name($dom);
     print_r($domNames);
?&gt;</pre>
        <p>This script will output all the domain names available on this connection (all of them are temporarily stored in <i>$domNames</i> array).</p>
      </div>
    </div>
    <div id="footer"></div>
  </body>
</html>