PHPackages                             morrelinko/simple-photo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. morrelinko/simple-photo

AbandonedArchivedLibrary[File &amp; Storage](/categories/file-storage)

morrelinko/simple-photo
=======================

Photo uploading and management made easy.

0.7.0(11y ago)10772MITPHPPHP &gt;=5.3.0

Since Jan 14Pushed 11y ago1 watchersCompare

[ Source](https://github.com/morrelinko/simple-photo)[ Packagist](https://packagist.org/packages/morrelinko/simple-photo)[ RSS](/packages/morrelinko-simple-photo/feed)WikiDiscussions develop Synced 2d ago

READMEChangelog (8)Dependencies (4)Versions (12)Used By (0)

SimplePhoto
===========

[](#simplephoto)

Handling photos in your web application has never been so *simple*.

[![Build Status](https://camo.githubusercontent.com/a103a4beb17e27af24d9fc7452aef4d21d452f4dade990cf7e8df9b7e12e35f4/68747470733a2f2f7472617669732d63692e6f72672f6d6f7272656c696e6b6f2f73696d706c652d70686f746f2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/morrelinko/simple-photo)

Installation
------------

[](#installation)

Through [Composer](http://getcomposer.org)

```
{
    "require": {
        "morrelinko/simple-photo": "0.*"
    }
}
```

Create the database using the schema below for the data store you will be using

- Sqlite DataStore: [Sql Query](https://github.com/morrelinko/simple-photo/blob/develop/schema/sqlite.sql)
- MySql DataStore: [Sql Query](https://github.com/morrelinko/simple-photo/blob/develop/schema/mysql.sql)

Uploading Photo
---------------

[](#uploading-photo)

```
$photoId = $simplePhoto->uploadFromPhpFileUpload($_FILES["image"]);
// Or
$photoId = $simplePhoto->uploadFromFilePath("/path/to/photo.png");
```

With support for accepting uploads from different sources.

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

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

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

Retrieving Photo
----------------

[](#retrieving-photo)

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

$photo->id();
$photo->url();
$photo->path();
$photo->fileMime();
$photo->storage();
$photo->fileSize();
$photo->fileExtension();
$photo->filePath();
$photo->createdAt();
...
```

Setup
-----

[](#setup)

SimplePhoto requires...

- Storage Manager: For Storing &amp; Managing registered storage adapters.
- Data Store: Database for persisting information about a photo.

```
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);
```

Get photos (+Transformation)
----------------------------

[](#get-photos-transformation)

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

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

The default transformation options available...

```
[
    'size' => [$width, $height]
    'rotate' => [$angle, ($background)]
]
```

[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
--------------------

[](#collection-of-photos)

```
$photos = $simplePhoto->collection([2, 23, 15]);

$photos->get(0); // gets photo '2'
$photos->get(1); // gets photo '23'
```

PhotoCollection come with a handful of methods for manipulating its items

```
// Creates a collection of photos
$photos = $simplePhoto->collection([2, 23, 15, 34, 21, 1, 64, 324]);

// Gets all as array
$allPhotos = $photos->all();

// Uses filter() method.
// This example creates a new photo collection containing only photos in 'local' storage
$localPhotos = $photos->filter(function($photo) {
    return $photo->storage() == 'local';
});

var_dump($localPhotos);
```

Push
----

[](#push)

```
// Probably gotten from a db
$users = [
    ['user_id' => 1, 'name' => 'John Doe', 'photo_id' => 2],
    ['user_id' => 2, 'name' => 'Mary Alice', 'photo_id' => 5]
];

$simplePhoto->push($users, array('photo_id'));

var_dump($users);

// Sample Output:
[
    ['user_id' => 1, 'name' => 'John Doe', 'photo_id' => 2, 'photo' => (Object SimplePhoto\PhotoResult)],
    ['user_id' => 2, 'name' => 'Mary Alice', 'photo_id' => 5, 'photo' => (Object SimplePhoto\PhotoResult)]
];
```

If you would like complete control on what is pushed to the array from the photo result,

you specify a callback as third argument to `push()`

```
$simplePhoto->push($users, array('photo_id'), function(&$item, $photo, $index, $name) {
    $item['photo_url'] = $photo->url();
});

var_dump($users);

// Sample Output:
[
    ['user_id' => 1, 'name' => 'John Doe', 'photo_id' => 2, 'photo_url' => 'http://example.com/files/2014/xxxxx.png'],
    ['user_id' => 2, 'name' => 'Mary Alice', 'photo_id' => 5, 'photo_url' => 'http://example.com/files/2014/xxxxx.png']
];
```

Supported Photo Sources
-----------------------

[](#supported-photo-sources)

- [FilePath Source](https://github.com/morrelinko/simple-photo/blob/develop/src/Source/FilePathSource.php)
- [PhpFileUpload Source](https://github.com/morrelinko/simple-photo/blob/develop/src/Source/PhpFileUploadSource.php)
- [Url Source](https://github.com/morrelinko/simple-photo/blob/develop/src/Source/UrlSource.php)
- [SymfonyFileUploadSource](https://github.com/morrelinko/simple-photo/blob/develop/src/Source/SymfonyFileUploadSource.php)

Supported Data Stores
---------------------

[](#supported-data-stores)

- [MySql Data Store](https://github.com/morrelinko/simple-photo/blob/develop/src/DataStore/MySqlDataStore.php)
- [Sqlite Data Store](https://github.com/morrelinko/simple-photo/blob/develop/src/DataStore/SqliteDataStore.php)
- [Memory Data Store](https://github.com/morrelinko/simple-photo/blob/develop/src/DataStore/MemoryDataStore.php)

Supported Storage
-----------------

[](#supported-storage)

- [Local Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/Storage/LocalStorage.php)
- [Remote Host Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/Storage/RemoteHostStorage.php)
- [Memory Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/Storage/MemoryStorage.php)
- [AwsS3 Storage](https://github.com/morrelinko/simple-photo/blob/develop/src/Storage/AwsS3Storage.php)

TODO
----

[](#todo)

- Add MongoDB Data Store

Credits
-------

[](#credits)

This code is principally developed and maintained by \[Laju Morrison\] ()

Licence
-------

[](#licence)

The MIT License (MIT). Please see [License File](https://github.com/morrelinko/simple-photo/blob/master/LICENSE) for more information.

Supported by

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Recently: every ~35 days

Total

9

Last Release

4344d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a28fa910f21fdbfeab53d5727fad337dc6680a16a7c69677dd89b712f1bfd7f5?d=identicon)[morrelinko](/maintainers/morrelinko)

---

Top Contributors

[![morrelinko](https://avatars.githubusercontent.com/u/2414096?v=4)](https://github.com/morrelinko "morrelinko (146 commits)")

---

Tags

imagestoragetransformuploadphotosimple-photo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/morrelinko-simple-photo/health.svg)

```
[![Health](https://phpackages.com/badges/morrelinko-simple-photo/health.svg)](https://phpackages.com/packages/morrelinko-simple-photo)
```

###  Alternatives

[sahusoftcom/eloquent-image-mutator

One solution for image uploads.

12016.3k](/packages/sahusoftcom-eloquent-image-mutator)[contributte/image-storage

Image storage for Nette framework

28749.3k1](/packages/contributte-image-storage)[ublaboo/image-storage

Image storage for Nette framework

2913.0k](/packages/ublaboo-image-storage)[marrouchi/upload-crop-image-bundle

Basic server side cropping behavior for Symfony2

121.1k](/packages/marrouchi-upload-crop-image-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
