PHPackages                             redeman/imgur-laravel - 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. [API Development](/categories/api)
4. /
5. redeman/imgur-laravel

ActiveLibrary[API Development](/categories/api)

redeman/imgur-laravel
=====================

Laravel Package for Imgur API. Provides easy access to the adyg/php-imgur-api-client library.

1.0.1(10y ago)92.6k3[1 PRs](https://github.com/MarkRedeman/Imgur-Laravel/pulls)MITPHPPHP &gt;=5.4.0

Since May 2Pushed 8y ago1 watchersCompare

[ Source](https://github.com/MarkRedeman/Imgur-Laravel)[ Packagist](https://packagist.org/packages/redeman/imgur-laravel)[ RSS](/packages/redeman-imgur-laravel/feed)WikiDiscussions master Synced 1mo ago

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

Description
-----------

[](#description)

A Laravel (4 / 5) Package for using the Imgur api. Internally we use [adyg/php-imgur-api-client](https://github.com/Adyg/php-imgur-api-client). The package provides a service provider, some configuration and a facade, such that you should be able to get started with writing your app immediately.

For more detailed documentation on how to use `adyg/php-imgur-api-client` you should look at their [documentation](https://github.com/Adyg/php-imgur-api-client/tree/master/doc).

### Quick example

[](#quick-example)

```
use Redeman\Imgur\Facades\Imgur;

$images = Imgur::api('gallery')->randomGalleryImages();

foreach ($images as $image)
{
    echo '';
}
```

Getting started
---------------

[](#getting-started)

First you will have to install the package using composer, this can be done by adding the following to your `require` block,

```
"redeman/imgur-laravel": "~1.0",

```

Next you can register the service provider by adding,

```
'Redeman\Imgur\ImgurServiceProvider',
```

to your providers array (in `config/app.php`). Imgur uses Oauth 2.0 to authenticate users. Therefore you have get a authentication token from your users if you want them to be able to view and upload images. In Laravel 5 you can do this by first add a route middleware to the `Redeman\Imgur\Middleware\AuthenticateImgur` middleware in your `App\Http\Kernel`.

```
/**
 * The application's route middleware.
 *
 * @var array
 */
protected $routeMiddleware = [
    // your other route middleware
    'imgur' => 'Redeman\Imgur\Middleware\AuthenticateImgur',
];
```

Next you should add the `imgur` middleware to any route were a user should be authenticated by Imgur. The `AuthenticateImgur` middleware will store and retrieve the user's access token. If the user is not authenticated by the Imgur (meaning your application doesn't know the user's access token), then the user will be redirected to a route with the name `imgur.authenticate`. If you are a Laravel 4 user, then you only need to add the service provider. This provider will register a `imgur` filter which you can use for your routes, see the example below how to do this. In the following section we show an example of some simple routes.

Example
-------

[](#example)

`routes.php`:

```
// Show the user a random image
Route::get('/', ['middleware' => ['imgur'], function() {
    $client = App::make('Imgur\Client');
    $images = $client->api('gallery')->randomGalleryImages();

    return View::make('imgur.images')->with('images', $images);
}]);

// Ask the user to authenticate using Imgur's services
Route::get('imgur/authenticate', ['as' => 'imgur.authenticate',  function() {
    $client = App::make('Imgur\Client');

    return View::make('imgur.authenticate')->with('imgurUrl', $client->getAuthenticationUrl());
}]);
```

If you are a Laravel 4 user, then you should substitute `middleware` with `before`.

`imgur.images.blade.php`:

```
Here are some images for you to enjoy:
@foreach ($images as $image)

@endforeach
```

`imgur.authenticate.blade.php`:

```
You need to register with Imgur in order to visit this page:
Click to authorize
```

Now you're all set! The next section describes how you can configure the package to use your client id, secret and a custom `TokenStorage`.

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

[](#configuration)

First publish the configuration file:

#### Laravel 4:

[](#laravel-4)

```
php artisan config:publish redeman/imgur-laravel

```

#### Laravel 5:

[](#laravel-5)

```
php artisan vendor:publish --provider="Redeman\Imgur\ImgurServiceProviderLaravel5"

```

Now you can fill in the appropriate values for `client_id` and `client_secret`. It is encouraged to use a `.env` which contains your client id and secret. Here is how you can do this in laravel 5:

```
/*
 * Public client id
 */
'client_id' => env('CLIENT_ID'),

/**
 * Client secret
 */
'client_secret' => env('CLIENT_SECRET'),
```

Read the [Laravel documentation](http://laravel.com/docs/5.0/configuration#environment-configuration) to learn more about environment configuration.

### Using a custom `TokenStorage`

[](#using-a-custom-tokenstorage)

The `AuthenticateImgur` middleware uses a `Redeman\Imgur\TokenStorage\Storage` interface to store a user's access token. By default we provide a `SessionStorage` which will save the data in the user's session. However you could also use a database or some other storage facility. To do this you will have to change the `token_storage` value in your `config/imgur.php` file to the name of the class that you want to use.

Todos:
------

[](#todos)

- More storage facilities by default
- Add tests for the middleware and filters

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

3799d ago

Major Versions

0.0.2 → 1.0.02015-12-22

### Community

Maintainers

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

---

Top Contributors

[![MarkRedeman](https://avatars.githubusercontent.com/u/1114829?v=4)](https://github.com/MarkRedeman "MarkRedeman (13 commits)")

---

Tags

apilaravelwrapperimgur

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/redeman-imgur-laravel/health.svg)

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

###  Alternatives

[aerni/laravel-spotify

A Laravel wrapper for the Spotify Web API

209145.6k](/packages/aerni-laravel-spotify)[php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

16553.3k1](/packages/php-tmdb-laravel)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)[deviddev/billingo-api-v3-wrapper

This is a simple Laravel wrapper for Billingo (billingo.hu) API V3 SwaggerHUB PHP SDK.

2216.3k](/packages/deviddev-billingo-api-v3-wrapper)[lasserafn/laravel-economic

Economic REST wrapper for Laravel

1118.5k](/packages/lasserafn-laravel-economic)

PHPackages © 2026

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