Skip to content

Commit

Permalink
Initial commit/version
Browse files Browse the repository at this point in the history
  • Loading branch information
tystuyfzand committed May 23, 2018
0 parents commit 473b520
Show file tree
Hide file tree
Showing 13 changed files with 901 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright 2018 Tyler Stuyfzand

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
SeaweedFS PHP Client
====================

A basic but functional PHP client for [seaweedfs](https://github.com/chrislusf/seaweedfs)

Usage
-----

Create an instance of the `SeaweedFS\SeaweedFS` class, optionally specifying `scheme` and `cache` for http/https and Volume lookup caching.

Example
-------

```php
<?php
$cache = new \SeaweedFS\Cache\FileCache('./cache');

$client = new SeaweedFS\SeaweedFS('127.0.0.1:9333', 'http', $cache);

// Upload a file and get the returned object (SeaweedFS\Models\File)
$file = $client->upload('test1234', 'test.txt');

// Update a file
$client->upload('Testing1234', 'test.txt', $file);

// Retrieve the file contents
$stream = $client->get($file->fid);

echo stream_get_contents($stream) . PHP_EOL;

// Delete a file
$client->delete($file->fid);

// Get a file's URL
echo "URL: " . $file->getFileUrl() . PHP_EOL;

// URLs can also be retrieved manually
$volume = $client->lookup($file->fid);

echo "URL (manual): " . $client->buildVolumeUrl($volume->getPublicUrl(), $file->fid) . PHP_EOL;
```

Other packages
--------------

* Flysystem-SeaweedFS
* Laravel-SeaweedFS
20 changes: 20 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "tystuyfzand/seaweedfs-client",
"description": "A SeaweedFS implementation for PHP based on Guzzle",
"type": "library",
"license": "ISC",
"authors": [
{
"name": "Tyler Stuyfzand",
"email": "[email protected]"
}
],
"require": {
"guzzlehttp/guzzle": "^6.3"
},
"autoload": {
"psr-4": {
"SeaweedFS\\": "src/"
}
}
}
249 changes: 249 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions src/Cache/CacheInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace SeaweedFS\Cache;

/**
* A base Cache interface that can be implemented as many different caches.
*
* @package SeaweedFS\Cache
*/
interface CacheInterface {
/**
* Check if the cache implementation contains the specified key.
*
* @param $key
* @return bool
*/
public function has($key);

/**
* Get the specified key from the cache implementation.
*
* @param $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null);

/**
* Set the value in the cache implementation.
*
* @param $key
* @param $value
* @param int $minutes
* @return mixed
*/
public function put($key, $value, $minutes = 0);

/**
* Remove a value from the cache.
*
* @param $key
* @return mixed
*/
public function remove($key);
}
Loading

0 comments on commit 473b520

Please sign in to comment.