Download the PHP package okaybueno/images without Composer

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

IMPORTANT ❗

This package has been discontinued so it won't receive any other update. If you're using it please consider migrating to another solution. There are many other great solutions out there (ie. "medialibrary") that this package does not provide any benefit whatsoever anymore.


Image

A package that provides an easy way to work with images attached to models.

Latest Version on Packagist Quality Score Total Downloads

Disclaimer

This package was originally released here, but since the future of that package is not clear, it has been forked and re-worked under this repository.

Goal

Pretty often we have to use images attached to models (like profile pictures) and the process to implement this is always pretty much the same: upload image, store it, resize it, move thumbnails and original to cloud storage and so on. Sometimes things get even a bit more complex and we have to re-size the existing images, remove the old ones and so on.

So the goal of this package is to provide a neat and clean way to work with these kind of images attached to models, in a way that allows us to store them (both locally and remotely) and work with them (resize them, remove old ones, etc), both synchronously and asynchronously, reducing the amount of work that we have to do to integrate this in our projects.

Installation

  1. Install this package by adding it to your composer.json or by running composer require okaybueno/images in your project's folder.
  2. For Laravel 5.5 the Service provider is automatically registered, but if you're using Laravel 5.4, then you must add the provider to your config/app.php file: OkayBueno\Images\ImageServiceProvider::class
  3. Publish the configuration file by running php artisan vendor:publish --provider="OkayBueno\Images\ImageServiceProvider"
  4. Open the configuration file (config/images.php) and configure the settings according to your needs. Keep reading to know what the parameters mean.
  5. Ready to go!

Usage

The package provides 5 different things:

Image Model

The model is located at OkayBueno\Images\Models\Image. You should include this model as a relation in all your models that may contain images. This model contains 2 main functions that just return some values:

+ thumbnails( $size = NULL, $onlyPath = FALSE): Calling this will return the thumbnails generated for this image. By default, the function returns the full URL for ALL thumbnails. You can also select just one size (1st param) or return just the path to the image (2nd param).

+ url(): Returns the full URL to the original image.

Configuration file

It contains the parameters that need to be configured to make the package work properly.

Image Service

The Image Service is bind to an interface located at OkayBueno\Images\Services\ImageServiceInterface.The service contains the next functions:

Events / Listeners

There are some events and listeners included:

EVENTS:

OkayBueno\Images\Events\ImageWasCreated: Triggered when a new image was successfully uploaded and created in the DB/local disk.
OkayBueno\Images\Events\ImageWasProcessed: Triggered when the image is processed and the thumbnails were generated (locally).
OkayBueno\Images\Events\ImageWasMovedToCloud: Triggered when the image (and all its thumbnails) were moved to the cloud disk.
OkayBueno\Images\Events\ImageWasDeleted: Triggered when an image gets deleted (soft deleted).

===========

LISTENERS:

OkayBueno\Images\Listeners\ProcessImageAsync: Processes the received image asynchronously (queued). It can subscribe to the ImageWasCreated event.
OkayBueno\Images\Listeners\ProcessImageSync: Processes the received image synchronously (not queued). It can subscribe to the ImageWasCreated event.
OkayBueno\Images\Listeners\MoveProcessedImagesToCloudImageAsync: Moves the processed image and its thumbnail to the cloud disk asynchronously (queued). It can subscribe to the ImageWasProcessed event.
OkayBueno\Images\Listeners\MoveProcessedImagesToCloudImageSync: Moves the processed image and its thumbnail to the cloud disk synchronously (not queued). It can subscribe to the ImageWasProcessed event.
OkayBueno\Images\Listeners\RemoveLocalImageAsync: Deletes the local files for the received image asynchronously (queued). It can subscribe to the ImageWasMovedToCloud event.
OkayBueno\Images\Listeners\RemoveLocalImageSync: Deletes the local files for the received image synchronously (not queued). It can subscribe to the ImageWasMovedToCloud event.

To configure them just add them to your EventServiceProvider located at app/Providers/EventServiceProvider.php

As you can see, there are Async and Sync events. Subscribe just to one of them, according to your needs.

Commands

There are 2 commands included, that help you maintain the images.

php artisan images:purge-deleted-images {--days=30}:

Takes all the images deleted --days or more days ago (30 by default) and destroys them from the DB and from the local and remote disks.

php artisan images:resize {--image-id=} {--image-type=} {--sizes=}

Resizes the given image (by -image-id) or the group of given images (by --image-type) to the new sizes provided via --sizes.

NOTE: --sizes should contain ALL the sizes, not only the new ones. All the other versions of the pic that do not exist in this parameter will be removed. This parameter should have this structure: "big:500x500,small:100x100,medium:x250".

Practical Example

Let's suppose you have a user entity with a profile pic. You should include the relation with the Image entity like this:

Whenever you need to update the image, you need to use the Image Service provided. We recommended that you handle the image creation and old images removal at once, so you can keep images updated and synchronized. An example of function would be the next one:

$image can be anything that can create an instance of an Intervention Image object.

Then, whenever you call your function to create or update your user, you can include this method to update the image:

In order to make all this work automatically, your EventServiceProvider should wire up the events and listeners:

This way, we are wiring up all the events to the listeners in order to:

You can of course set this listeners to be processed automatically (by replacing 'Async' by 'Sync' in the name of the listener).

You can also decide if you use cloud disks, or if just store files just locally, etc... For example, you could choose not to move the files to the cloud and process them asynchronously, in which case you would have just something like this:

That's all! Simply put: the way you configure your events and listeners wil define the way that the files will be stored.

Changelog

-- No official version released yet --

Credits

Bugs & contributing

To-dos

License

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


All versions of images with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
illuminate/config Version 5.*
illuminate/database Version 5.*
illuminate/console Version 5.*
illuminate/queue Version 5.*
illuminate/http Version 5.*
illuminate/filesystem Version 5.*
okaybueno/validation Version 1.0.*
intervention/image Version ^2.3
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 okaybueno/images contains the following files

Loading the files please wait ....