Download the PHP package devmahmoudmustafa/laravel-imagekit without Composer

On this page you can find all versions of the php package devmahmoudmustafa/laravel-imagekit. 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-imagekit

Laravel ImageKit

Laravel ImageKit

Latest Version PHP Version Laravel Version

Overview

The Laravel ImageKit package (v1.1.0) is a comprehensive image management tool that allows developers to handle various image operations such as uploading, resizing, watermarking, compressing, and storing images. This package integrates seamlessly with Laravel's Storage system, providing full support for local storage, cloud storage (S3, GCS, Azure), and maximum flexibility for diverse use cases.


Table of Contents

  1. Features
  2. Installation
  3. Configuration
  4. Quick Start
  5. Storage Disks
  6. Methods Reference
  7. Examples
  8. Events
  9. Error Handling
  10. Support and Contribution

Features

The ImageKit package provides a comprehensive set of features for image management:

📤 Image Upload & Validation

🖼️ Image Resizing

🗜️ Image Compression

🎨 Watermarking

💾 Storage Management

📁 File Naming Strategies

🖼️ Gallery Operations

🗑️ Image Deletion

🔍 Image Retrieval

🎯 Fluent API

📢 Events System

� Flexible Return Data

�🛠️ Configuration & Customization

✅ Error Handling

🔄 State Management


Installation

Step 1: Install the Package

Install the package using Composer:

Step 2: Publish the Configuration File

Publish the configuration file to customize default settings:

This command will create a imagekit.php file in the config directory.


Configuration

Default Configuration

The package comes with a comprehensive configuration file. Here's what you can configure:

Configuration Options Explained

disk

The storage disk to use. Can be any disk defined in config/filesystems.php:

default_saved_path

Default path where images are saved (relative to disk root).

allowed_extensions

Allowed image file extensions for uploads.

max_file_size

Maximum file size in kilobytes. Set to null for no limit.

max_dimensions

Maximum image dimensions in pixels. Set to null for no limit.

naming_strategy

File naming strategy:

enable_multi_size

Enable global multi-size resizing. When enabled, images are automatically resized to multiple sizes.

multi_size_dimensions

Define custom size dimensions for multi-size resizing.

dimensions

Default dimensions for single image resize.

aspectRatio

Whether to maintain aspect ratio when resizing (default: true).

compression_quality

Default compression quality (0-100). Set to null for dynamic quality based on file size.

enable_watermark

Enable watermark globally for all images.

watermark

Default watermark settings:

watermark_storage_path

Default path where uploaded watermark images are saved (relative to disk root). This path is used when you pass an UploadedFile as the watermark image.

return_keys

Specify which data to return after saving an image. Available keys:

Behavior:

Default: ['name'] (returns only the image name as string)


Quick Start

Basic Usage

Using Cloud Storage


Storage Disks

The package fully supports Laravel's Storage abstraction, allowing you to use any storage driver.

Setting Disk

Default Storage Disks

Using the public Disk

When using the public disk (default), images are saved in storage/app/public/ directory.

Important: To access images directly from URLs (e.g., http://your-domain.com/storage/uploads/images/image.jpg), you must create a symbolic link by running:

This command creates a symbolic link from public/storage to storage/app/public, making stored files publicly accessible.

Without running this command, you won't be able to access images via direct URLs, and you'll need to use the package's response() or getImageUrl() methods to serve images.

Example:

Creating Custom Storage Disks

You can create any custom disk configuration in config/filesystems.php. The package will work with any disk you define.

Example: Save Images Directly in public/ Directory

If you want to save images directly in the public/ folder (instead of storage/app/public/), create a custom disk:

  1. Add the disk configuration in config/filesystems.php:

  2. Use the custom disk in your code:

Note: Saving directly to public/ folder doesn't require storage:link command, but it's generally not recommended for production as files in public/ are directly accessible and harder to manage.

Example: Custom Local Disk

You can create disks pointing to any directory:

Then use them:

Cloud Storage Setup

Amazon S3

  1. Configure in config/filesystems.php:

  2. Use in code:

Google Cloud Storage

Similar setup, use 'gcs' as disk name.

Azure Blob Storage

Similar setup, use 'azure' as disk name.


Methods Reference

Image Methods

setImage($image) / image($image)

Set the image file to be processed.

Parameters:

Example:

setImages(array $images) / images(array $images)

Set multiple images for gallery processing.

Example:


Path & Name Methods

setImagePath($path) / path($path) / saveTo($path)

Set the path where images will be saved (relative to disk root).

Example:

setImageName($name) / name($name)

Set a custom name for the image file.

Example:

setExtension($extension) / extension($extension)

Set a custom file extension.

Example:


Resize Methods

setDimensions($width, $height) / resize($width, $height) / dimensions($width, $height)

Resize image to specific dimensions.

Parameters:

Example:

setMultiSizeOptions($sizes) / sizes($sizes)

Resize image to multiple sizes.

Parameters:

Example:


Compression Methods

compressImage($compress, $quality) / compress($compress, $quality)

Compress the image.

Parameters:

Example:


Watermark Methods

setWatermark(...) / watermark(...)

Apply watermark to the image.

Parameters:

Example:


Storage Methods

setDisk($disk)

Set the storage disk to use.

Parameters:

Example:

getDisk()

Get the current storage disk being used.

Returns: string - Current disk name

Example:


Save Methods

saveImage() / save()

Save the image after applying all modifications.

Returns: string|array - Based on return_keys config:

Example:

saveGallery($imageColumnName, $fkColumnName, $fkId, $altText)

Save multiple images as a gallery.

Parameters:

Returns: array - Array of results based on return_keys config:

Example:


Utility Methods

make()

Create a fresh instance of the service (useful for avoiding state pollution).

Example:

reset()

Reset the service to initial state.

Example:


Delete Methods

deleteImage($imageName, $path, $sizes)

Delete a single image.

Parameters:

Returns: bool

Throws: InvalidArgumentException if image is in root directory when path is extracted from imageName

Examples:

deleteGallery($imagesNames, $path, $sizes)

Delete multiple images.

Parameters:

Returns: int - Number of successfully deleted images

Throws: InvalidArgumentException if any image is in root directory when path is extracted from imageName

Examples:


Examples

Example 1: Basic Upload

Example 2: Resize and Compress

Example 3: Multi-Size with Watermark

Example 3.1: Watermark with UploadedFile

Example 3.2: Watermark with Dimensions

Example 4: Using Cloud Storage (S3)

Example 5: Custom File Naming

Example 6: Gallery with Database Integration

Example 7: Fluent API Chain

Example 8: Dynamic Disk Switching

Example 8.1: Custom Return Keys

Example 8.2: Get All Image Metadata

Example 8.3: Gallery with Return Keys

Example 9: Display Image in Browser

Example 10: Download Image

Example 11: Get Image URL

Example 12: Temporary URL (Cloud Storage)


Image Retrieval Methods

All image retrieval methods support an optional $disk parameter. If not provided, the current disk from config or the last set disk will be used.

Retrieval Methods

getImage($path, $disk)

Get image content from storage.

Parameters:

Returns: string|null - Image content or null if file doesn't exist

Example:

response($path, $disk, $options)

Get HTTP response for displaying image in browser.

Parameters:

Returns: \Illuminate\Http\Response

Example:

download($path, $name, $disk, $options)

Get download response for image.

Parameters:

Returns: \Symfony\Component\HttpFoundation\StreamedResponse

Example:

getImageUrl($path, $disk)

Get the full URL for an image.

Parameters:

Returns: string - Full URL

Example:

getImagePath($path, $disk)

Get the full filesystem path for an image (for local disk operations).

Parameters:

Returns: string - Full filesystem path

Example:

imageExists($path, $disk)

Check if image file exists.

Parameters:

Returns: bool

Example:

temporaryUrl($path, $expiration, $disk, $options)

Get temporary URL for image (useful for cloud storage like S3).

Parameters:

Returns: string - Temporary URL

Example:


Events

The package fires events at key points during image processing. See EVENTS.md for complete documentation.

Available Events

Example: Listening to Events


Error Handling

The package throws InvalidArgumentException for validation errors. Always use try-catch blocks:

Common Errors


Support and Contribution

For support or to contribute to this package, visit the GitHub repository.

License

This package is open-sourced software licensed under the MIT license.


All versions of laravel-imagekit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/filesystem Version ^9.0|^10.0|^11.0|^12.0
intervention/image Version ^2.7
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 devmahmoudmustafa/laravel-imagekit contains the following files

Loading the files please wait ...