Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
morrelinko committed Jan 19, 2014
1 parent e848b9e commit f1309cc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,60 @@ $photoId = $simplePhoto->uploadFromFilePath("/path/to/photo.png");
## Retrieving Photo

```php
$simplePhoto->getPhoto($photoId);
$photo = $simplePhoto->get($photoId);

$photo->url();
$photo->path();
$photo->fileMime();
$photo->fileExtension();
```

## Setup

SimplePhoto requires a...
1. Storage Manager: For Storing & Managing registered storage adapters.
2. Data Store: (Such as database) For persisting photo data.

```php
// Coming soon
use SimplePhoto\Storage\LocalStorage;
use SimplePhoto\StorageManager;
use SimplePhoto\DataStore\SqliteDataStore;
use SimplePhoto\SimplePhoto;

// Create a local storage adapter
$localStorage = new LocalStorage('/path/to/project/root/', 'photos');

// Create a storage manager
$storageManager = new StorageManager();

// Adds one or more registered storage adapters
$storageManager->add('local', $localStorage);

// Create Data Store
$dataStore = new SqliteDataStore(['database' => 'photo_app.db']);

// Create Our Simple Photo Object
$simplePhoto = new SimplePhoto($storageManager, $dataStore);
```

## Retrieving photos (+Transformation)

If you want to get a re-sized photo, use the "transform" options of the second argument

```php
$photo = $simplePhoto->get($photoId, array(
"transform" => array(
"size" => array(200, 200)
)
));
$photo = $simplePhoto->get($photoId, [
"transform" => [
"size" => [200, 200]
]
]);
```

Other transformation options will be made available...

## Credits

This code is principally developed and maintained by [Laju Morrison] (https://github.com/morrelinko)

## Licence

The MIT License (MIT). Please see [License File](https://github.com/morrelinko/simple-photo/blob/master/LICENSE) for more information.
Expand Down
9 changes: 4 additions & 5 deletions src/SimplePhoto/SimplePhoto.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ class SimplePhoto
*/
public function __construct(StorageManager $storageManager = null, DataStoreInterface $dataStore = null, $options = array())
{
$this->options = array_merge(array(
'defaults_root' => null,
'defaults_path' => null
), $options);

if ($storageManager != null) {
$this->setStorageManager($storageManager);
}
Expand Down Expand Up @@ -98,6 +93,8 @@ public function setDataStore(DataStoreInterface $dataStore)
* @param mixed $photoData
* @param array $options
*
* @see SimplePhoto::uploadFrom()
*
* @return int
*/
public function uploadFromPhpFileUpload($photoData, array $options = array())
Expand All @@ -109,6 +106,8 @@ public function uploadFromPhpFileUpload($photoData, array $options = array())
* @param mixed $photoData
* @param array $options
*
* @see SimplePhoto::uploadFrom()
*
* @return int
*/
public function uploadFromFilePath($photoData, array $options = array())
Expand Down

0 comments on commit f1309cc

Please sign in to comment.