Download the PHP package emsifa/random-image without Composer

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

Random Image

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Random Image is a Laravel helper to get random image and store it in your application. It is designed to be used in model factory to seed dummy data.

Currently we have 3 random image provider you can choose:

  1. LoremFlickr (default)
  2. Unsplash
  3. LoremPicsum (doesn't support search query)

Please see their website for the license information.

Features

Installation

You can install the package via composer:

Remove --dev flag if you are planned to use this library in production

After that, you may want to publish the config file with:

It will generate config/random-image.php file in your project directory.

Usage Example

Get Random Image URL

If you just want to get image url from provider, you can use url method like an example below:

It will return https://loremflickr.com/600/400/ which will resulting different image if you use it in <img/> tag.

You can also specify size and search terms inside make method like this:

The URL returned will be different for every provider. For example, if you use Unsplash provider, the URL generated would be like this:

You can change provider in config/random-image.php file.

Store Image

You can use store or storeAs method to download and store image into your filesystem disk.

You can specify disk by defining disk parameter:

Use storeAs if you want to specify filename:

You can also get stored URL just by chaining it with url() method like example below:

Or if you want to get the filename only, you can chain it with name() method.

Usage Example in Model Factory

This package is designed to be used in the model factory, which is why methods above return a string of image path/url so you can just store it in the database. To use it in the model factory, you can just call the method in the example above in your model factory like this:

When you seed posts data using factory above, you can use Storage::disk('public')->url($post->image) to get the url.

Copy and Manipulate Downloaded Image

In most case you may want to create a thumbnail version of the same image. We wrap some APIs from intervention/image to do that kind of stuff.

For example, in Post factory above, we want to define thumbnail field that contain a path for 300x200px version of the image:

NEW: You can use previous method to do the same thing as example above, but much simpler.

Here is a list of manipulation methods you can use:

All methods above is available on the ImageResult instance which is returned from store method. So you can use it not only to copied image. But the original stored image too.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of random-image with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/contracts Version ^10.0
intervention/image Version ^2.7
spatie/laravel-package-tools Version ^1.13.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 emsifa/random-image contains the following files

Loading the files please wait ....