Download the PHP package nh/mediable without Composer

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

Installation

Install the package via composer:

Publish the config and the Media model:

If you need to publish the database you can use:

To make a model mediable, add the Mediable trait to your model:

You can retrieve the media (order by a position) of a model:

Or you can retrieve the first media of a model:

Retrieve all media by a type:

You can check if a model has some media:

If you need to resize the picture media (JPEG/PNG), add the sizes in the config mediable.php at 'sizes':

If you need to add a watermark you can activate the functionnality in the config mediable.php, add the sizes in the config mediable.php at 'sizes':

By default the media are upload in the public disk, but you can change this in the config mediable.php.

The media are saved in:

Views

Add a media

The names of the inputs must be: media_to_add[KEY][name] and media_to_add[KEY][file] and in option you can add media_to_add[KEY][position]

Edit a media

The name of the input must be: media_to_update[KEY][name] and in option you can add media_to_update[KEY][position]

Delete a media

The name of the input must be: media_to_delete[] and the value must be the ID

Model

Attributes

You can retrieve the filename of a media Return: 42.jpg

You can retrieve the base folder of a media Return: posts

You can retrieve the folder of a media Return: posts/images

You can retrieve the format of a media The format is defined by the extension, exemple a .jpg will return 'image'

You can retrieve the default url of a media Return: posts/images/42.jpg

You can retrieve the url of a the thumbnail of a media (Only if the format is 'image') Return: posts/images/thumbnails/42.jpg

Function

You can retrieve the url of a media, and you can add a subfolder. Exemple: 42.jpg which is resized with a 100px height => 'posts/images/h-100/42.jpg'

You can retrieve the absolute url of a media from the server, and you can add a subfolder. Exemple: 42.jpg which is resized with a 100px height => '/Users/YOURUSERNAME/Web/MYPROJECT/public/storage/FOLDER/images/SUBFOLDER/42.png'

You can retrieve the file of a media, and you can add a subfolder. Exemple: 42.jpg which is resized with a 100px height => 'posts/images/h-100/42.jpg'

Events

You can use the MediaEvent for dispatch events that happen to the media. You can pass a name, the parent model, the media model (or null) and the number of media affected


All versions of mediable with dependencies

PHP Build Version
Package Version
Requires intervention/image Version ^2.5
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 nh/mediable contains the following files

Loading the files please wait ....