Download the PHP package daycode/stup-images without Composer

On this page you can find all versions of the php package daycode/stup-images. 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 stup-images

Laravel Stup Image

Image uploads for Laravel without tables or migrations. One statement to validate, resize, convert and store an image on any disk.

Tests Coverage PHP Laravel Downloads

That single statement checks the real MIME type, resizes, converts to WebP, gives the file a unique name, writes it to your disk (local, public, S3, ...) and returns the path to save in your database. You don't need a media table, a migration or any setup.


Contents


Features

Requirements

Stup Image PHP Laravel Intervention Image
2.x 8.2 – 8.5 12.x, 13.x (13.x needs PHP 8.3+) 3.11+
1.x not declared not declared 3.11.2

You also need the PHP gd or imagick extension.

Installation

The service provider and the StupImage facade are auto-discovered. You can optionally publish the config and check your image driver:

If you store images on the public disk, link the storage folder once:

Quick start

Store the path ($image->path, for example avatars/01j9zk3v7c8e2x4m6n8p0q2r4s.webp) in your database. With the path you can build URLs, delete or replace the image later without remembering the directory.

Usage

Storing an image

Resizing

Operations run in the order you call them. Use when() to apply one conditionally:

Formats and quality

The original format is kept unless you convert it:

You can also set default_format in the config to convert every upload, for example to WebP.

Disks, directories, names and visibility

Replacing an image

The old image, including its variants, is deleted only after the new image has been stored. If the new upload fails, the old one stays. $user->avatar may be null.

Multiple images

If any file fails, the files already stored are removed again and the exception is rethrown.

Deleting and URLs

Deleting a missing file doesn't throw. delete() returns false in that case.

Presets

Define named option sets in config/stup-image.php:

Presets support the keys resize, cover, scale, contain (as [width, height]), format and quality. Options you call after preset() override the preset.

Variants

Store extra sizes next to the image in one go:

Variants are generated from the original upload. A variant uses its preset's format, or the image's format when the preset has none. delete() and replace() remove the variants of every configured preset too.

To generate the variants on the queue instead of during the request, add queue():

Queued variants are generated from the stored image, so apply size-reducing options only through variants when you queue them.

Eloquent integration

UploadedFile macro

Events

Event Payload When
Daycode\StupImage\Events\ImageStored $event->image (StoredImage) After an image (with its variants) is stored. Batches dispatch after all files succeed. Queued variants dispatch one event each.
Daycode\StupImage\Events\ImageDeleted $event->disk, $event->path After an existing image is deleted.

Error handling

Every failure throws a subclass of Daycode\StupImage\Exceptions\StupImageException:

Exception When
InvalidImageException Not an UploadedFile, a failed upload, or contents that can't be decoded as an image
DisallowedMimeTypeException The detected MIME type isn't in allowed_mime_types
ImageTooLargeException Over max_size, max_width or max_height
StorageException The disk failed to write, read or delete
DriverNotAvailableException The configured gd/imagick driver is unknown or not installed

A wrong configuration or argument (unknown preset, invalid quality, ...) throws an InvalidArgumentException.

You should still validate requests with Laravel's image, mimes and max rules so users get friendly messages. Stup Image's checks are the safety net behind them.

Testing

StupImage::fake() fakes every disk the package uses. Images are still processed for real, so dimensions and formats are accurate, and every operation is recorded:

Available assertions: assertStored(?path|callback, ?times), assertStoredCount(), assertNothingStored(), assertDeleted(), assertNotDeleted() and assertNothingDeleted(). You can also read the records with storedImages() and deletedImages().

Configuration

About visibility: new S3 buckets have ACLs disabled, and setting a visibility makes uploads to them fail. That's why the default is null.

About original naming: the client filename is slugged (My Photo.JPG → my-photo.jpg) and deduplicated (my-photo-1.jpg).

For a custom naming strategy, implement Daycode\StupImage\Contracts\Namer and set its class name in naming.

Stup Image or Spatie Media Library?

spatie/laravel-medialibrary is an excellent, far more complete package. Here's a comparison to help you pick:

Stup Image Spatie Media Library
Database Your own string column A media table (migration)
Setup composer require Migration, model interface and trait, config
Files Images only Any file type
Conversions Presets and variants (sync or queued) Conversions, responsive images
Multiple files per model Your own relation or JSON column Built-in collections
Custom properties, ordering, downloads — ✅
Learning curve Minutes Hours

Pick Stup Image when you want an avatar, cover or product image stored with a path in an existing column, and nothing more. Pick Spatie Media Library when you manage many files per model, non-image files, custom properties or responsive images.

Upgrading from v1

v2 is a rewrite, but the v1 Stupable trait still works as a deprecated wrapper, so you can upgrade gradually. See UPGRADE.md for the breaking changes and the v1 → v2 mapping.

Security

If you discover a security vulnerability, please follow SECURITY.md.

Contributing

Contributions are welcome. Please read CONTRIBUTING.md. Before you open a PR, run these:

See CHANGELOG.md for what's new.

Credits and license

Stup Image is open-source software licensed under the GitHub.


All versions of stup-images with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/bus Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
intervention/image Version ^3.11
spatie/laravel-package-tools Version ^1.19
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 daycode/stup-images contains the following files

Loading the files please wait ...