WeedPhp
PHP client for Weed-FS, a simple and highly scalable distributed file system., (*1)
Weed-FS:
http://code.google.com/p/weed-fs/, (*2)
Status:
Ready for testing / In Development, (*3)
Testing:
dev-master: , (*4)
Installation:
Installation through composer
If you already use composer this is the most simple way to use WeedPhp in your project., (*5)
Add to your composer.json, (*6)
"require": {
"micjohnson/weed-php": "v0.1"
}
Install through composer.phar, (*7)
php composer.phar update micjohnson/weed-php
Installation without composer
Clone the repo, (*8)
git clone https://github.com/micjohnson/weed-php.git
Create an autoloader. There is an example in test/autoload.php, (*9)
Then include the autoloader in your project., (*10)
include_once('weed-php/test/autoload.php');
Documentation:
Create a WeedPhp object in your project, by passing the location of your master weed-fs server., (*11)
<?php
// ...
$weedPhp = new WeedPhp\Client('localhost:9333');
WeedPhp provides functions for most of the weed-fs REST calls., (*12)
assign($count = 1, $replication = null)
Assign returns a json response including the file id your file(s) will use, and where to store the file, using store., (*13)
When storing files with weed-fs the logic flow is assign then store. Assign reserves $count locations for files to be stored (using a single file id)., (*14)
A string can be passed for replication, defining the type of replication this file will be stored with. see http://code.google.com/p/weed-fs/#Rack-Aware_and_Data_Center-Aware_Replication, (*15)
Note that if you have a count greater than one, append _1, _2, _3, etc. on the file id for the subsequent files. The first file still uses just the file id., (*16)
store($volumeServerAddress, $fileId, $file)
This stores a single file., (*17)
$volumeServerAddress should be the location returned from assign()., (*18)
$fileId should be the file id returned from assign()., (*19)
$file raw file data to be stored., (*20)
storeMultiple($volumeServerAddress, $fileId, array $files)
This is meant to be used when assigning multiple file versions. This will automatically loop through your files, and append _1, _2, etc. on the file id, as it stores the files., (*21)
$volumeServerAddress should be the location returned from assign()., (*22)
$fileId should be the file id returned from assign()., (*23)
$files array of raw file datas to be stored., (*24)
lookup($volumeId)
Returns a json response with the locations where the volume is stored, (*25)
$volumeId is the number before the comma in the fileId., (*26)
eg.
fid = 3,01637037d6
volumeId = 3, (*27)
retrieve($volumeServerAddress, $fileId)
Retrieves the raw file data from a volume server., (*28)
$volumeServerAddress should be the location returned from assign()., (*29)
$fileId should be the file id returned from assign()., (*30)
delete($volumeServerAddress, $fileId)
Deletes file from volume server. Note that there is not a deleteMultiple, and if you assigned/stored multiple files you should delete them each individually., (*31)
$volumeServerAddress should be the location returned from assign()., (*32)
$fileId should be the file id returned from assign()., (*33)
status()
Gets status from your weed-fs master server, (*34)