PHPackages                             marksitko/laravel-unsplash - 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. marksitko/laravel-unsplash

ActiveLibrary

marksitko/laravel-unsplash
==========================

Provides a fluent Unsplash API for Laravel

2.3.0(1y ago)90114.8k↓12.9%16[5 issues](https://github.com/marksitko/laravel-unsplash/issues)MITPHPPHP ^8.0

Since Mar 11Pushed 1y ago2 watchersCompare

[ Source](https://github.com/marksitko/laravel-unsplash)[ Packagist](https://packagist.org/packages/marksitko/laravel-unsplash)[ Docs](https://github.com/marksitko/laravel-unsplash)[ RSS](/packages/marksitko-laravel-unsplash/feed)WikiDiscussions master Synced 1mo ago

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

Powerful Unsplash package for Laravel
=====================================

[](#powerful-unsplash-package-for-laravel)

Provides a fluent api to use the Unsplash within Larvel applications. Use public actions or store images directly in your storage and persists all copyright informations automatically with the databse connector.

[![Latest Version on Packagist](https://camo.githubusercontent.com/4f009fb57eecaa3500088e57e49bf57e731f79ab1c9c24ede2c8f403bcdb58f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61726b7369746b6f2f6c61726176656c2d756e73706c6173682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marksitko/laravel-unsplash)[![Build Status](https://camo.githubusercontent.com/d695787c56c551f868bada85869c5251e5f1febac996ed92a8f33e9c2b0b3597/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d61726b7369746b6f2f6c61726176656c2d756e73706c6173682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/marksitko/laravel-unsplash)[![Quality Score](https://camo.githubusercontent.com/a2568af4739b76b14180ace10cef77fe34ab16a0eecd9430aa9978dce262e183/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d61726b7369746b6f2f6c61726176656c2d756e73706c6173682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/marksitko/laravel-unsplash)[![Total Downloads](https://camo.githubusercontent.com/090c0b8a2182e7ad9e6a463a3d6b3e37d706c2155ac5bfc1c0103ce57783fb73/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61726b7369746b6f2f6c61726176656c2d756e73706c6173682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marksitko/laravel-unsplash)

Install
-------

[](#install)

```
$ composer require marksitko/laravel-unsplash
```

Laravel-Unsplash comes with package discovery and Laravel will register the service provider and facade automatically. Just in case you wanna add it manually, you should provide it in `config/app.php`

**Service provider**

```
'providers' => [
    //...
    MarkSitko\LaravelUnsplash\UnsplashServiceProvider::class,
];
```

**Facade**

```
'aliases' => [
    //...
    'Unsplash' => MarkSitko\LaravelUnsplash\Facades\Unsplash::class,
];
```

Next you should publish the configuration.

```
$ php artisan vendor:publish --tag=config
```

###### Optional

[](#optional)

If you wanna use Laravel-Unsplash with the database connector you have to publish the migration files.

```
$ php artisan vendor:publish --tag=migrations
```

It creates 2 migrations. One to store additional informations about stored image and one morph table to use it with the `HasUnsplashables` trait.

Configuration
-------------

[](#configuration)

You have to provide a unsplash api access key in your `.env` file. [Read how to generate a Unsplash API key](https://unsplash.com/documentation#creating-a-developer-account)

```
UNSPLASH_ACCESS_KEY=YOUR_GENERATED_API_KEY_FROM_UNSPLASH

```

Optional configurations:

```
# default is false
UNSPLASH_STORE_IN_DATABASE=BOOLEAN

# default is local
UNSPLASH_STORAGE_DISK=YOUR_STORAGE_DISC

```

Basic Usage
-----------

[](#basic-usage)

Take a look at the full Unsplash API documentation

**Random Photos**

```
// Returns the http response body.
$twoRandomPhotosOfSomePeoples = Unsplash::randomPhoto()
    ->orientation('portrait')
    ->term('people')
    ->count(2)
    ->toJson();

// Store the image in on your provided disc
$theNameFromTheStoredPhoto = Unsplash::randomPhoto()
    ->orientation('landscape')
    ->term('music')
    ->randomPhoto()
    ->store();
];
```

**Photos**

```
$photos = Unsplash::photos()->toJson();
$photo = Unsplash::photo($id)->toJson();
$photosStatistics = Unsplash::photosStatistics($id)->toJson();
$trackPhotoDownload = Unsplash::trackPhotoDownload($id)->toJson();
```

**Users**

```
$user = Unsplash::user($username)->toJson();
$userPortfolio = Unsplash::userPortfolio($username)->toJson();
$userPhotos = Unsplash::userPhotos($username)->toJson();
$userLikes = Unsplash::userLikes($username)->toJson();
$userCollections = Unsplash::userCollections($username)->toJson();
$userStatistics = Unsplash::userStatistics($username)->toJson();
```

**Search**

```
$search = Unsplash::search()
    ->term('buildings')
    ->color('black_and_white')
    ->orientation('squarish')
    ->toJson();

$searchCollections = Unsplash::searchCollections()
    ->query('events')
    ->page($pageNumber)
    ->toJson();

$searchUsers = Unsplash::searchUsers()
    ->query('search_term')
    ->toJson();
```

**Collections**

```
$collectionsList = Unsplash::collectionsList()
    ->page($pageNumber)
    ->perPage($itemsPerPage)
    ->toJson();

$featuredCollection = Unsplash::featuredCollection()
    ->page($pageNumber)
    ->perPage($itemsPerPage)
    ->toJson();

$showCollection = Unsplash::showCollection()
    ->id($collectionId)
    ->toJson();

$showCollectionPhotos = Unsplash::showCollectionPhotos()
    ->id($collectionId)
    ->toJson();

$showCollectionRelatedCollections = Unsplash::showCollectionRelatedCollections()
    ->id($collectionId)
    ->toJson();
```

**Topics**

```
$topicsList = Unsplash::topicsList()
    ->page($pageNumber)
    ->perPage($itemsPerPage)
    ->toJson();

$showTopic = Unsplash::showTopic()
    ->id($topicIdOrSlug)
    ->toJson();

$showTopicPhotos = Unsplash::showTopicPhotos()
    ->id($topicIdOrSlug)
    ->toJson();
```

**Stats**

```
$totalStats = Unsplash::totalStats()->toJson();
$monthlyStats = Unsplash::monthlyStats()->toJson();
```

Usage with Database
-------------------

[](#usage-with-database)

If you wanna persist automaticly some informations (i.e. Copyrights) about you stored images you have to run the published migrations. In case you dont have ran the optional command, we start at the beginning:

```
$ php artisan vendor:publish --tag=migrations
```

```
$ php artisan migrate
```

When migration is successfull, you have to adjust the `.env`

```
UNSPLASH_STORE_IN_DATABASE=true

```

Now when you execute `store()` on the Unsplash client, the image is stored in your provided disc and informations like

- the unsplash photo id
- the stored image name
- author name
- author link

However, these informations are all required to use a unsplash photo on your website.

**Example with Unsplash Client**

```
// Returns the created unsplash asset record
$databaseRecord = Unsplash::randomPhoto()->store();
```

You are now also able to use the build in `UnsplashAsset` Model **Example with UnsplashAsset Model**

```
// Returns the created unsplash asset record
$databaseRecord = UnsplashAsset::api()->randomPhoto()->store();

// Get an stored unsplash asset
$unsplashAsset = UnsplashAsset::find($id);
```

You can also use the `HasUnsplashables` Trait on any model.

**Example with HasUnsplashables Trait on the User Model**

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use MarkSitko\LaravelUnsplash\Traits\HasUnsplashables;

class User extends Authenticatable
{
    use HasUnsplashables;

    // ...
}
```

Now you are able to use it like:

```
// store the unsplash asset in a morphToMany relation
$unsplashAsset = Unsplash::randomPhoto()->store();
User::unsplash()->save($unsplashAsset);

// retrive all related unsplash assets
User::find($userId)->unsplash();
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance43

Moderate activity, may be stable

Popularity48

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~182 days

Recently: every ~218 days

Total

11

Last Release

440d ago

Major Versions

0.1.0-beta → 1.0.02020-04-15

1.1.2 → 2.0.02022-03-08

PHP version history (7 changes)0.1.0-betaPHP ^7.1

1.0.0PHP ^7.2

1.1.0PHP ^7.3

1.1.1PHP &gt;=7.2|&gt;=8.0

2.0.0PHP ^8.0

2.0.1PHP ^8.0|^8.1

2.1.0PHP ^8.0|^8.1|^8.2

### Community

Maintainers

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

---

Top Contributors

[![marksitko](https://avatars.githubusercontent.com/u/36196670?v=4)](https://github.com/marksitko "marksitko (3 commits)")[![hopkins385](https://avatars.githubusercontent.com/u/98618192?v=4)](https://github.com/hopkins385 "hopkins385 (1 commits)")[![LTroya](https://avatars.githubusercontent.com/u/6491259?v=4)](https://github.com/LTroya "LTroya (1 commits)")[![oleynikd](https://avatars.githubusercontent.com/u/3976868?v=4)](https://github.com/oleynikd "oleynikd (1 commits)")[![razisayyed](https://avatars.githubusercontent.com/u/911192?v=4)](https://github.com/razisayyed "razisayyed (1 commits)")

---

Tags

laravellaravel-unsplashunsplashmarksitkolaravel-unsplash

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marksitko-laravel-unsplash/health.svg)

```
[![Health](https://phpackages.com/badges/marksitko-laravel-unsplash/health.svg)](https://phpackages.com/packages/marksitko-laravel-unsplash)
```

###  Alternatives

[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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