Download the PHP package jegex/laravel-media without Composer

On this page you can find all versions of the php package jegex/laravel-media. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-media

jegex/laravel-media

Latest Version on Packagist Tests Total Downloads PHP Version Laravel Version

Powerful media management package for Laravel applications. Handle file uploads, image conversions, responsive images, and video thumbnails with ease. Inspired by spatie/laravel-medialibrary.

Table of Contents

Installation

Install the package via Composer:

Post-Installation Steps

Step 1: Publish Configuration & Migration

Step 2: Run Migration

Step 4: Configure Storage Disk (Optional)

In config/media.php or your .env file, set the default storage disk:

Then create the symbolic link for public disk:

Step 5: Configure Queue (Optional)

If you want image conversions to run asynchronously:

Quick Start

Add the HasMedia trait to your model:

Now you can attach media:

Usage

Adding Media via Model

Add the HasMedia trait to your model:

Now you can attach media:

Adding Media Directly (Standalone)

Since the model_type and model_id columns are nullable, you can create media without associating it to any model:

This is useful for global media libraries, CDN assets, or when you don't need to associate media with a specific model.

Retrieving Media

Media Properties

Custom Properties

Rendering Media

Image Conversions

Define conversions in your model:

Retrieve converted images:

Conversion Methods

Method Description
width($px) Set width
height($px) Set height
fit(Fit $fit) Set fit mode (contain, cover, fill, etc.)
format($format) Set output format (webp, avif, jpg, png)
quality($quality) Set output quality (1-100)
brightness($value) Adjust brightness (-100 to 100)
contrast($value) Adjust contrast
blur($value) Apply blur effect
gamma($value) Adjust gamma
flip($direction) Flip image (h, v)
optimize() Optimize output image
queued() Process conversion on queue
nonQueued() Process conversion synchronously
manipulate($name, $value) Add custom manipulation

Image Generators

The package supports multiple file types out of the box:

Image Optimizers

Optimizers are applied automatically when optimize() is called:

Format Optimizer
JPEG Jpegoptim
PNG Pngquant, Optipng
SVG Svgo
GIF Gifsicle
WebP Cwebp
AVIF Avifenc

Responsive Images

Responsive images are generated automatically for image media files.

The package calculates optimal widths using FileSizeOptimizedWidthCalculator (30% smaller per variation) and generates a blurred tiny placeholder for progressive loading.

Queue System

Conversions and responsive images can be processed asynchronously.

Configuration

Per-Conversion Queue Setting

Jobs

Job Description
PerformConversionsJob Processes image conversions
GenerateResponsiveImagesJob Generates responsive image variations

Vapor Uploads

For Laravel Vapor deployments, enable the upload route:

Routes

Method Route Description
POST /media-vapor Store new media from Vapor
POST /media-vapor/finished/{mediaId} Mark media upload as finished
POST /media-vapor/parameters Get upload parameters for S3 direct upload

ZIP Export

Export media collections as ZIP archives for bulk downloads.

Export from Model

Export from Single Media

Filter by Conversion

The ZIP export uses maennchen/zipstream-php for memory-efficient streaming. Files are added directly to the stream without loading them entirely into memory.

Facade Usage

The package provides a LaravelMedia facade for convenient access to media operations without needing a model:

Configuration

The full configuration file (config/media.php):

Environment Variables

Variable Default Description
MEDIA_DISK public Default storage disk
MEDIA_QUEUE '' Queue name
QUEUE_CONNECTION sync Queue connection
QUEUE_CONVERSIONS_BY_DEFAULT true Queue conversions by default
QUEUE_CONVERSIONS_AFTER_DB_COMMIT true Run after database commit
IMAGE_DRIVER gd Image processing driver
FFMPEG_PATH /usr/bin/ffmpeg FFMPEG binary path
FFPROBE_PATH /usr/bin/ffprobe FFProbe binary path
FFMPEG_TIMEOUT 900 FFMPEG timeout (seconds)
FFMPEG_THREADS 0 FFMPEG thread count
MEDIA_DOWNLOADER_SSL true SSL verification for downloads
MEDIA_TEMPORARY_URL_DEFAULT_LIFETIME 5 Temporary URL lifetime (minutes)
MEDIA_PREFIX '' Storage path prefix
FORCE_MEDIA_LIBRARY_LAZY_LOADING true Force lazy loading
ENABLE_MEDIA_LIBRARY_VAPOR_UPLOADS false Enable Vapor upload routes

Advanced Usage

Custom Path Generator

Create a custom path generator:

Register it in config:

Or per-model:

Media Lifecycle Events

The MediaObserver handles:

Blade Component

Testing

Run with coverage:

Run a specific test:

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-media with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
spatie/image Version ^3.3.2
maennchen/zipstream-php Version ^3.1
spatie/temporary-directory Version ^2.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jegex/laravel-media contains the following files

Loading the files please wait ...