Download the PHP package makeabledk/laravel-cloud-images without Composer

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

Laravel Cloud Images

Latest Version on Packagist Build Status StyleCI

This package provides a convenient to manage Google App Engine Images API through Laravel.

Images API allows you to upload an image once to your GCS bucket and afterwards generate unlimited thumbnails just by requesting the specified size in the image-url. No delay, storage concerns or re-generate commands.

Important

Please checkout https://github.com/makeabledk/appengine-php-imageserver for more information on Images API and how to setup an imageserver for your project.

This package assumes you already have a configured App Engine imageserver and GCS Bucket.

Installation

You can install this package via composer:

Add a new gcs disk to your filesystems.php config

See https://github.com/spatie/laravel-google-cloud-storage for more details about configuring filesystems.php.

Creating a Google Service Account

You can create a service account key file through these steps

Upgrading from 0.16.x -> 0.17.0

This release introduces new database fields for responsive images. Please publish migrations and optionally generate placeholders.

Upgrading from 2.x --> 3.x

Starting with version 3 this package uses spatie/laravel-google-cloud-storage instead of superbalist/laravel-google-cloud-storage.

Basic usage

Upload an image

Easily upload a \Illuminate\Http\File or \Illuminate\Http\UploadedFile to your GCS bucket and create an image-url for it.

Delete an image

Using the delete method will both delete the bucket file and destroy serving-image URL.

Note that image-serving URL's can take up to 24 hours to clear from cache

The good stuff: Generating images on the fly

Now that our image is served by Google, we can manipulate it on the fly.

All you have to do to start manipulating images, is an instance of ImageFactory:

Contain to max dimension

Example result:

Example image 1

Crop to dimensions

Example result:

Example image 1

Example image 2

Stretch to dimensions

Example result:

Example image 1

Blur

Example result:

Example image 1

Custom parameters (advanced)

If the functionality you need is not provided by the package, you can specify your own google-compatible parameters:

Example image 3

Checkout our makeabledk/appengine-php-imageserver repository for more information on available parameters.

Media Library usage (recommended)

For the examples so far there has been no need to publish any migrations. You are completely free to only use this package for uploading and retrieving image files from Google.

However, while uploading and serving images is all well and good, you will likely need to store the references in your database and attach them to some existing models.

This package will likely provide you with most of the functionality you'll ever need for dealing with images in your application.

Extended installation

1. Install rutorika/sortable package which is used to track sort-order (required)

2. Install intervention/image to read and store exif-data on your images (optional)

3. Publish and run migrations

Uploading images

Model attachment with multiple images

First, use the HasImages trait on your parent model.

Now you have an images() belongs-to-many relationship you can utilize as you normally would:

Ordering attached images

Images will be kept in the order you attach them. However, you are free to reorder them afterwards.

Checkout the Sortable many to many section of the rutorika/sortable package.

Model attachment with a single image

If your model is expected to have just one image, you may use the convenient image() helper provided by the same HasImages trait.

On the Image instance you may use the make() method to generate the size you need.

Differentiating between image types

Sometimes you may wish to have different types of 'single images' on a model. Use the optional tag parameter to achieve this behavior.

Note: Tagging is only intended through the image($tag) helper as the rutorika/sortable package does not differentiate between tags when applying order.

Replacing images

Use the replaceWith method on the Image model to swap any Image with another while preserving attachments.

This is especially useful in combination with the image() helper:

Pro tip: Use an eloquent mutator to set the new image

In your controller it would work seamlessly when validating and filling the model (Laravel 5.5 example).

Configuring image sizes per model

Often times you want a few pre-configured sizes available. In this example we would like 'square' and 'wide' available on our Product model.

We may extend the Image model and use that on our Product->images() relationship.

Now you can access the sizes simply by referencing them as properties.

Remember to add the sizes to $appends attribute if you want them available when casting to array:

In Laravel 5.5, ApiResources would be a great place to append your image sizes as well.

Responsive images

Given the previous example of a product image, we may use the responsive() method to generate a collection of responsive image sizes.

By doing this, we can serve srcset optimized images on our website.

Of course all the available transformations are still available for responsive images.

The approach for responsive images is heavily inspired by the spatie/laravel-medialibrary package and offer the same functionality (including placeholders).

Consider reading their documentation for a very thorough explanation of the concept.

Also be sure to checkout their demo here: Responsive images demo

Finally consider checking out ResponsiveTest.php for more usage examples this package offers.

Cleaning up old images

Deleting an image

When deleting an Image instance, the CloudImage::delete() method is automatically fired to delete the actual bucket file.

Deleting images with no attachment

Over time your images table may get bloated with images that no longer has model-attachments to them.

Use the cloud-images:cleanup command to delete images (along with the actual bucket files) that are no longer used.

Testing

You can run the tests with:

Contributing

We are happy to receive pull requests for additional functionality. Please see CONTRIBUTING for details.

Credits

License

Attribution-ShareAlike 4.0 International. Please see License File for more information.


All versions of laravel-cloud-images with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/container Version ^10.0|^11.0
illuminate/filesystem Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
spatie/laravel-google-cloud-storage Version ^2.0
guzzlehttp/guzzle Version ^7.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 makeabledk/laravel-cloud-images contains the following files

Loading the files please wait ....