Skip to content

Installation

Install the package via Composer:

bash
composer require imsus/laravel-imgproxy

Publish Configuration

Publish the configuration file:

bash
php artisan vendor:publish --tag="laravel-imgproxy-config"

Publish the Blade components:

bash
php artisan vendor:publish --tag="laravel-imgproxy-components"

Configuration

Configure your .env file:

env
IMGPROXY_ENDPOINT=http://localhost:8080
IMGPROXY_KEY=your_hex_key_here
IMGPROXY_SALT=your_hex_salt_here
IMGPROXY_DEFAULT_SOURCE_URL_MODE=encoded
IMGPROXY_DEFAULT_OUTPUT_EXTENSION=jpeg

Configuration Options

OptionDescriptionDefaultRequired
endpointimgproxy server URLhttp://localhost:8080Yes
keyHex-encoded signing key for HMAC-SHA256nullNo*
saltHex-encoded signing saltnullNo*
default_source_url_modeHow to encode source URLsencodedNo
default_output_extensionDefault output formatjpegNo

*The key and salt are required only if you want to generate signed URLs.

Generating Keys

Generate secure signing keys using the built-in artisan command:

bash
php artisan imgproxy:key

This command generates 64-character hex strings for IMGPROXY_KEY and IMGPROXY_SALT, saves them to your .env file, and displays them in the console.

TIP

You can also generate keys manually using openssl rand -hex 32, but the artisan command is faster and more convenient.

CAUTION

The key and salt must be in hex-encoded format (64 characters each).

Requirements

  • PHP 8.2+
  • Laravel 10.x or 11.x
  • imgproxy server (self-hosted or cloud)

Released under the MIT License.