PHP Classes

Skylable SX PHP Client: Store and retrieve files in Skylable cloud cluster

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 63 All time: 10,429 This week: 488Up
Version License PHP version Categories
skylable-sx 1.0BSD License5.4.0PHP 5, Files and Folders, Web services
Description 

Author

This package can store and retrieve files in Skylable cloud cluster.

It can send HTTP requests to a Skylable SX endpoint Web server API to perform several types of operations with files in their cloud clustered file system.

Currently it can get the cluster node list, get the volumes list, locate a volume, get the users list, get the file list, get file metadata, get job status, get a file, download file, delete a file, put file or upload a file.

Picture of Martin Pircher
  Performance   Level  
Name: Martin Pircher <contact>
Classes: 2 packages by
Country: Austria Austria
Age: ???
All time rank: 165215 in Austria Austria
Week rank: 180 Up1 in Austria Austria Up

Documentation

Skylable SX PHP Client

A standalone PHP library for interacting with Skylable SX (a distributed object-storage software for data clusters by http://www.skylable.com).

Build Status

Installation

The library is listed at packagist and should be installed with composer.

{
    "require": {
        "mplx/skylablesx": "dev-master"
    }
}

Source code is available at github and bitbucket.

Usage

$sx = new Sx('__YOUR_KEY__', '__YOUR_SX_CLUSTER__');
$sx = new Sx('__YOUR_KEY__', '__YOUR_SX_CLUSTER__', __YOUR_TCP__PORT__);

$sx = new Sx();
$sx->setAuth('__YOUR_KEY__');
$sx->setEndpoint('__YOUR_SX_CLUSTER__');
$sx->setPort(__YOUR_TCP__PORT__);

$sx->setSSL(false);         // do not use SSL
$sx->setSSL(true);          // SSL, verify certificate
$sx->setSSL(true, false);   // SSL, do not verify certificate

Operations

getNodeList

$nodes = $sx->getNodeList();

// List all nodes
echo PHP_EOL . 'Available nodes:' . PHP_EOL;
$nodes = $sx->getNodeList();
foreach ($nodes->nodeList as $node => $ip) {
    echo 'Node #' . $node . ': IP ' . $ip . PHP_EOL;
}

getVolumeList

$volumes = $sx->getVolumeList();

// List all volumes
$samplevol = null;
$volumes = $sx->getVolumeList();
echo PHP_EOL . 'Available volumes:' . PHP_EOL;
foreach ($volumes->volumeList as $vol => $meta) {
    $samplevol = $vol;
    echo $vol . ' (replicas=' . $meta->replicaCount . ', maxRev=' . $meta->maxRevisions . ')' . PHP_EOL;
}

locateVolume

$locate = $sx->locateVolume($volume);

// Locate volume
$samplevol = 'playground';
echo PHP_EOL . 'Locate volume: ' . $samplevol . PHP_EOL;
$locate = $sx->locateVolume($samplevol);
foreach ($locate->nodeList as $node => $ip) {
    echo 'Node #' . $node . ': IP ' . $ip . PHP_EOL;
}

getUserList

$users = $sx->getUserList();

// List all users
$users = $sx->getUserList();
echo PHP_EOL . 'List all users:' . PHP_EOL;
foreach ($users as $user => $properties) {
    echo $user . PHP_EOL;
}

getFileList

$files = $sx->getFileList($volume);
$files = $sx->getFileList($volume, $filter);

// List all files in volume $samplevol
$samplevol = 'playground';
$files = $sx->getFileList($samplevol);
echo PHP_EOL . 'List files on volume ' . $samplevol .':' . PHP_EOL;
foreach ($files->fileList as $file => $meta) {
    echo $file . PHP_EOL;
}

// List all *.deb files in volume $samplevol
$samplevol = 'playground';
$samplefilter = '*.deb';
$files = $sx->getFilesList($samplevol, $samplefilter);
echo PHP_EOL . 'List ' . $samplefilter . ' files on volume ' . $samplevol .':' . PHP_EOL;
foreach ($files->fileList as $file => $meta) {
    echo $file . PHP_EOL;
}

getFileMetadata

$meta = $sx->getFileMetadata($volume, $file)

getJobStatus

$status = $sx->getJobStatus($requestId, $minPollInterval, $maxPollInterval, $maxRetries);

getFile

$file = $sx->fetchFile($volume, $file);

// Fetch file to PHP var
$samplevol = 'playground';
$samplefile = 'sx_0.3-1~wheezy_amd64.deb';
echo PHP_EOL . 'Fetching file ' . $samplevol . $samplefile . PHP_EOL;
$file = $sx->fetchFile($samplevol, $samplefile);

downloadFile

$result = $sx->downloadFile($volume, $file, $target);

// Download file to local filesystem
$samplevol = 'playground';
$samplefile = '/sx_0.3-1~wheezy_amd64.deb';
$sampletarget = './sx_0.3-1~wheezy_amd64.deb';
$result = $sx->downloadFile($samplevol, $samplefile, $sampletarget);

deleteFile

$result = $sx->deleteFile($volume, $file);

// Delete file
$samplevol = 'playground';
$samplefile = '/sx_0.4-1~wheezy_amd64.deb';
echo PHP_EOL . 'Delete file ' . $samplevol . $samplefile . PHP_EOL;
$result = $sx->deleteFile($samplevol, $samplefile);
while ($result->requestStatus == 'PENDING') {
    echo "Delete pending... " . PHP_EOL;
    sleep(1);
    $result = $sx->getJobStatus($result->requestId, 1, 2, 1);
}
if ($result->requestStatus == 'OK') {
    echo "Sucessfully deleted file" . PHP_EOL;
} elseif ($result->requestStatus == 'ERROR') {
    echo "Error deleting file: " . $result->requestMessage . PHP_EOL;
}

putFile

$result = putFile($volume, $file, $body);

// Upload ("put") file (file content from PHP var)
$samplevol = 'playground';
$samplefile = '/upload.txt';
$samplecontent = 'dynamic text: ' . microtime();
echo PHP_EOL . 'Putting file ' . $samplevol . $samplefile . PHP_EOL;
$result = $sx->putFile($samplevol, $samplefile, $samplecontent);
while ($result->requestStatus == 'PENDING') {
    echo "Upload pending... " . PHP_EOL;
    sleep(1);
    $result = $sx->getJobStatus($result->requestId, 1, 2, 1);
}
if ($result->requestStatus == 'OK') {
    echo "Upload sucessfull" . PHP_EOL;
} elseif ($result->requestStatus == 'ERROR') {
    echo "Upload failed: " . $result->requestMessage . PHP_EOL;
}

uploadFile

$result = uploadFile($volume, $file, $source);

// Upload file (file from filesystem)
$source = './sx_0.9-1-1~wheezy_amd64.deb';
$samplevol = 'playground';
$target = '/sx_0.9-1-1~wheezy_amd64.deb';
echo PHP_EOL . 'Uploading file ' . $source . ' to volume ' . $samplevol . $target . PHP_EOL;
$result = $sx->uploadFile($samplevol, $target, $source);
while ($result->requestStatus == 'PENDING') {
    echo "Upload pending... " . PHP_EOL;
    sleep(1);
    $result = $sx->getJobStatus($result->requestId, 1, 2, 1);
}
if ($result->requestStatus == 'OK') {
    echo "Upload sucessfull" . PHP_EOL;
} elseif ($result->requestStatus == 'ERROR') {
    echo "Error uploading file: " . $result->requestMessage . PHP_EOL;
}

License

Licensed under the BSD 3-Clause License.


  Files folder image Files (16)  
File Role Description
Files folder imagesrc (1 directory)
Files folder imagetests (7 files)
Accessible without login Plain text file build.properties Data phing build
Accessible without login Plain text file build.xml Data phing build
Accessible without login Plain text file composer.json Data composer
Accessible without login Plain text file LICENSE.txt Lic. BSD 3-Clause License
Accessible without login Plain text file README.md Doc. Readme

  Files folder image Files (16)  /  src  
File Role Description
Files folder imagemplx (1 directory)

  Files folder image Files (16)  /  src  /  mplx  
File Role Description
Files folder imageskylablesx (4 files)

  Files folder image Files (16)  /  src  /  mplx  /  skylablesx  
File Role Description
  Plain text file Sx.php Class SX class
  Plain text file SxCurl.php Class SXCurl class
  Plain text file SxException.php Class SXException class
  Plain text file SxRequest.php Class SXRequest class

  Files folder image Files (16)  /  tests  
File Role Description
  Accessible without login Plain text file AuthorizationTest.php Test unit test
  Accessible without login Plain text file bootstrap.php Test unit test bootstrap
  Accessible without login Plain text file ExceptionTest.php Test unit test
  Accessible without login Plain text file phpunit.xml Data phpunit cfg
  Accessible without login Plain text file SxCurlTest.php Test unit test
  Accessible without login Plain text file SxRequestTest.php Test unit test
  Accessible without login Plain text file SxTest.php Test unit test

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:63
This week:0
All time:10,429
This week:488Up