PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Getting Started

Once you have registered with Nirvanix, you're ready to store your first file on the IMFS. The most common operations that you will need to do on the IMFS are creating a new file, downloading an existing file, and deleting a file. Zend_Service_Nirvanix provides convenience methods for these three operations.

<?php
$auth 
= array('username' => 'your-username',
              
'password' => 'your-password',
              
'appKey'   => 'your-app-key');

$nirvanix = new Zend_Service_Nirvanix($auth);
$imfs $nirvanix->getService('IMFS');

$imfs->putContents('/foo.txt''contents to store');

echo 
$imfs->getContents('/foo.txt');

$imfs->unlink('/foo.txt');

The first step to using Zend_Service_Nirvanix is always to authenticate against the service. This is done by passing your credentials to the Zend_Service_Nirvanix constructor above. The associative array is passed directly to Nirvanix as POST parameters.

Nirvanix divides its web services into namespaces. Each namespace encapsulates a group of related operations. After getting an instance of Zend_Service_Nirvanix, call the getService() method to create a proxy for the namespace you want to use. Above, a proxy for the IMFS namespace is created.

After you have a proxy for the namespace you want to use, call methods on it. The proxy will allow you to use any command available on the REST API. The proxy may also make convenience methods available, which wrap web service commands. The example above shows using the IMFS convenience methods to create a new file, retrieve and display that file, and finally delete the file.

Zend Framework