GetBlimp / filepreviews-laravel by jpadilla

Laravel 5 service provider for FilePreviews.io
7,020
6
2
Package Data
Maintainer Username: jpadilla
Maintainer Contact: jpadilla@blimp.io (José Padilla)
Package Create Date: 2015-11-23
Package Last Update: 2015-11-28
Home Page: http://filepreviews.io
Language: PHP
License: MIT
Last Refreshed: 2024-11-11 15:09:34
Package Statistics
Total Downloads: 7,020
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 6
Total Watchers: 2
Total Forks: 0
Total Open Issues: 2

filepreviews-laravel

Laravel 5 service provider for FilePreviews.io

Installation

$ composer require filepreviews/filepreviews-laravel

To use the FilePreviews Service Provider, you must register the provider when bootstrapping your Laravel application.

Find the providers key in your config/app.php and register the FilePreviews Service Provider.

    'providers' => [
        // ...
        
        FilePreviews\Laravel\FilePreviewsServiceProvider::class,
    ]

Find the aliases key in your config/app.php and add the FilePreviews facade alias.

    'aliases' => [
        // ...
        
        'FilePreviews' => FilePreviews\Laravel\FilePreviewsFacade::class,
    ]

To customize the configuration file, publish the package configuration using Artisan.

$ php artisan vendor:publish

Update your settings in the generated config/filepreviews.php configuration file.

<?php

return [
    'api_key' => env('FILEPREVIEWS_API_KEY', ''),
    'api_secret' => env('FILEPREVIEWS_API_SECRET', '')
];

Usage

In order to use the FilePreviews PHP client library within your app, you need to resolve it from the Laravel Service Container.

$fp = app('FilePreviews');
$fp->generate($url, $options);

Handling Webhooks

Point a route to the controller.

Route::post('filepreviews/webhook', '\FilePreviews\Laravel\WebhookController@handleWebhook');

Since FilePreviews webhooks need to bypass Laravel's CSRF verification, be sure to list the URI as an exception in your VerifyCsrfToken middleware:

protected $except = [
    'filepreviews/webhook',
];