Download the PHP package igaster/laravel-image-versions without Composer

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

Laravel License Build Status

How it works

Enchace your models to produce different versions of any image (eg for thumbnail/watermark etc). Produced images are saved in separate subfolders for future requests. You only have to define some operations on the Image. File management and caching are handled for you. You can use any local or remote filesystem you need!

Installation

This package depends on the Intervention package to manipulate images.

First you should install Intervention: Read the instructions. Don't forget to publish it's configuration file, we will place some options there!

Next you can install this package with:

composer require "igaster/laravel-image-versions"

How to use

This package decorates any Eloquent Model that holds a representation of an Image. To implement follow these steps:

1. Setup your model:

Your model should use the ImageVersionsTrait. For example:

The only requirement for your model is to define the relativePath() method which will return the path to the file (relative to public folder). For example if you place your images in a Photos folder and store the naked filename in the filename attribute then your implementatin could be:

PS: If you are using Amazon S3 (or any other flysystem disk) then this method should return the path to your file from your disk's root.

2. Create your Transformation classes:

You can create any number of versions of a single image. To define a version you have to create a Transformation class that extends the AbstractTransformation and implement the apply() method. You will receive an Intervention\Image\Image object, where you can perform any operations.

A short example of a trasformation class:

The Intervention package provides a rich API to edit your images. Refer to their documentation for a list of all available methods

3. Request an image version

Very simple! Call the version() method on your Eloquent model. (For the following example suppose that Photo class is an Eloquent model that stores an image's filename)

Here's what is going to happen:

On the $thumb object you received, you can retreive information about the new version of the image:

If you want to force rebuilding the new image even if it has been cached before you can call rebuildVersion() instead of version()

Passing Parameters

You may pass any number of parameters when you request a version of an Image:

You will receive these values in the apply() method of your Transformation class as additional parameters:

Please note that the the Transformation is executed only if the new image does not exist. If it has been called in the past, then the stored image will be returned instead of creating a new one. s

Using Flysystem disks (eg Amazon S3)

You can swap your local filesystem with any remote file system such as the Amazon S3.

Using Aliases

You can define the default namespace of your Transformation classes in image.php configuration file:

Now you have the option to use the Transformation class shortname as an alias instead of the full nampespaced classname. eg:

This is quite usefull when you are using image versions inside your Blade files.

Saving lifecycle

Two callbacks will be fired from your Transformation class before and after saving the new image. Your can implement these methods if in your classes if you need extra functionality:

Take a look at the AbstractTransformation to see how saving an image is handled by default. Note that you should not write the image to a file by yourself (writeImage('...')), since this is already handled for you.

Custom Callbacks

You can define any number of callback functions that will be executed BEFORE your Transformation is applied. To set your callbacks call beforeTransformation() from your Eloquent model, before calling the version() method:

Usefull if you want to peform some preprocessing. You can chain any number of beforeTransformation() calls.

Additionaly you can pass your own parameters to your callbacks:

Decorator Pattern: You still have your models!

Morever the return value of the version() funtion (instance of Version) is decorator that wraps your original Photo model. This means that you can perform ANY operation you could perform on your original model.

You can find more information about the decorator used at igaster/eloquent-decorator


All versions of laravel-image-versions with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 5.*
igaster/eloquent-decorator Version ~1.0
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 igaster/laravel-image-versions contains the following files

Loading the files please wait ....