New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

redeman/imgur-laravel

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

Larablocks Analysis

redeman/imgur-laravel works with Laravel 4 and 5 (latest release 1.0.1, Dec 23, 2015), all past end of life: no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 4 and 5, past end of life
  • No release in the last 12 months (last: Dec 23, 2015)
  • 0 downloads a month (needs 10,000)
  • 9 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Dec 23, 2015.
  • No releases in the last 12 months.
  • First released: May 2, 2015.
  • 2 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.

Install
composer require redeman/imgur-laravel
Latest Version:1.0.1
PHP:>=5.4.0
Laravel:4 · 5
License:MIT
Last Updated:Oct 4, 2017
Links: GitHub  ·  Packagist
Maintainer: MarkRedeman

Description

A Laravel (4 / 5) Package for using the Imgur api. Internally we use 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.

Quick example

use Redeman\Imgur\Facades\Imgur;

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

foreach ($images as $image)
{
    echo '<li><img src="' . $image->getLink() . '"></li>';
}

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

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:

<p>Here are some images for you to enjoy:</p>
@foreach ($images as $image)
    <img src="{{ $image->getLink() }}">
@endforeach

imgur.authenticate.blade.php:

<h2>You need to register with Imgur in order to visit this page:</h2>
<a href="https://github.com/MarkRedeman/Imgur-Laravel/blob/HEAD/{{ $imgurUrl }}">Click to authorize</a>

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

First publish the configuration file:

Laravel 4:
php artisan config:publish redeman/imgur-laravel
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 to learn more about environment configuration.

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:

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

Related Packages

fenix007/apiwrapper

Laravel API wrapper

14 1
masterfermin02/vicidial-api-wrapper

Beautiful and simple Implementation to integrate Vicidial API

1,030 31
skizu/simpleapi

Simple api wrapper with easy caching and throttling

170 2
railroad/mailora

Wrapper for Laravel's email functionality that adds HTTP API and front-end-dev-f...

80,972 0
deviddev/billingo-api-v3-wrapper

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

26,340 22

Version History

Version Released PHP Laravel License
1.0.1 >=5.4.0 ~5.0 || ~4.0 MIT
1.0.0 >=5.4.0 ~5.0 || ~4.0
0.0.2 >=5.4.0 ~5.0 || ~4.0
0.0.1 >=5.4.0 ~5.0 || ~4.0