Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
morrelinko committed Apr 18, 2014
2 parents 57eaf40 + a65775f commit 1319184
Show file tree
Hide file tree
Showing 38 changed files with 1,429 additions and 403 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
composer.lock
/vendor
composer.lock
.*/
33 changes: 26 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SimplePhoto
---------------------
Photo uploading and management made easy
Photo uploading and management made easy.

[![Build Status](https://travis-ci.org/morrelinko/simple-photo.png?branch=master)](https://travis-ci.org/morrelinko/simple-photo)

Expand Down Expand Up @@ -29,6 +29,20 @@ $photoId = $simplePhoto->uploadFromPhpFileUpload($_FILES["image"]);
$photoId = $simplePhoto->uploadFromFilePath("/path/to/photo.png");
```

With support for accepting uploads from different sources.

```php
$photoId = $simplePhoto->upload(new YourUploadSource($imageData));
```

The two upload methods shown above actually are just like aliases/shortcuts for doing this

```php
$photoId = $simplePhoto->upload(new PhpFileUploadSource($_FILES["image"]));
// Or
$photoId = $simplePhoto->upload(new FilePathSource("/path/to/photo.png"));
```

## Retrieving Photo

```php
Expand All @@ -37,20 +51,21 @@ $photo = $simplePhoto->get($photoId);
$photo->id();
$photo->url();
$photo->path();
$photo->mime();
$photo->fileMime();
$photo->storage();
$photo->fileSize();
$photo->fileExtension();
$photo->filePath();
$photo->createdAt();
...
```

## Setup

SimplePhoto requires...

* Storage Manager: For Storing & Managing registered storage adapters.
* Data Store: (Such as database) For persisting photo data.
* Data Store: Database for persisting information about a photo.

```php
use SimplePhoto\Storage\LocalStorage;
Expand Down Expand Up @@ -86,7 +101,7 @@ $photo = $simplePhoto->get($photoId, [
]);
```

All transformation options available...
The default transformation options available...

```php
[
Expand All @@ -95,7 +110,10 @@ All transformation options available...
]
```

Arguments in brackets are optional
[You could implement your own transformer and add more transformation options](http://simplephoto.morrelinko.com/docs/transformer)

Arguments in parenthesis are optional


## Collection of photos

Expand Down Expand Up @@ -125,7 +143,7 @@ $localPhotos = $photos->filter(function($photo) {
var_dump($localPhotos);
```

## Push (in english 'push photo result into')
## Push

```php
// Probably gotten from a db
Expand Down Expand Up @@ -171,6 +189,7 @@ var_dump($users);
* [FilePath Source](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Source/FilePathSource.php)
* [PhpFileUpload Source](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Source/PhpFileUploadSource.php)
* [Url Source](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Source/UrlSource.php)
* [SymfonyFileUploadSource](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Source/SymfonyFileUploadSource.php)

## Supported Data Stores

Expand All @@ -183,10 +202,10 @@ var_dump($users);
* [Local Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Storage/LocalStorage.php)
* [Remote Host Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Storage/RemoteHostStorage.php)
* [Memory Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Storage/MemoryStorage.php)
* [AwsS3 Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/SimplePhoto/Storage/AwsS3Storage.php)

## TODO

* Add AWS Storage
* Add MongoDB Data Store

## Credits
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"email": "morrelinko@gmail.com"
}
],
"suggest": {
"aws/aws-sdk-php": "For use with Aws S3 Storage"
},
"autoload": {
"psr-4": {
"SimplePhoto\\": ["src", "tests"]
Expand All @@ -18,6 +21,7 @@
"imagine/imagine": "~0.5.0"
},
"require-dev": {
"aws/aws-sdk-php": "~2",
"mockery/mockery": "dev-master@dev"
}
}
2 changes: 2 additions & 0 deletions src/DataStore/MemoryDataStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,7 @@ public function getPhotos(array $photoIds)
public function deletePhoto($photoId)
{
unset($this->store[$photoId]);

return true;
}
}
2 changes: 1 addition & 1 deletion src/DataStore/SqliteDataStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace SimplePhoto\DataStore;

use SimplePhoto\Utils\FileUtils;
use SimplePhoto\Toolbox\FileUtils;

/**
* @author Laju Morrison <morrelinko@gmail.com>
Expand Down
9 changes: 4 additions & 5 deletions src/PhotoResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PhotoResult
/**
* @var
*/
protected $mime;
protected $fileMime;

/**
* @var string
Expand Down Expand Up @@ -93,7 +93,6 @@ class PhotoResult

/**
* @param array $photoData
*
* @return PhotoResult
*/
public function __construct($photoData)
Expand Down Expand Up @@ -180,9 +179,9 @@ public function filePath()
/**
* @return string
*/
public function mime()
public function fileMime()
{
return $this->mime;
return $this->fileMime;
}

/**
Expand Down Expand Up @@ -270,7 +269,7 @@ public function setStorage($storage)
*/
public function setFileMime($mime)
{
$this->mime = $mime;
$this->fileMime = $mime;
}

/**
Expand Down

0 comments on commit 1319184

Please sign in to comment.