Download the PHP package melsaka/mediafile without Composer

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

MediaFile

Simplify the process of adding files and images to your Laravel app.

Features

Example Usage

Upload a file to the server, and place it into the images directory in 'storage/app/public/media/images'.

This will create and returns a Media record that can be used to refer to the file.

You can also update a media record by simply do so:

And delete media record by simply:

Installation

Add the package to your Laravel app using composer

Register the package's service provider in config/app.php. In Laravel versions 5.5 and beyond, this step can be skipped if package auto-discovery is enabled.

Publish the config file (src/config/mediafile.php) of the package using artisan.

Publish the assets files (src/public/) of the package using artisan.

Run the migrations to add the required tables to your database.

(Optional) You can also publish controllers, migrations and views using these artisan commands.

How To Use

Before you upload images you must create a folder to put images into it, folders are created into storage/app/public/media/ folder by default,

but you can customize this to create them into storage/app/public/ folder from the config/mediafile.php file.

We can use the MediaFolder class to easily create folders like this:

The store method accpets 2 params the $name of the folder and the $order in numbers. it creates unique slug automatically based on the $name value.

To edit a folder you must have in your $request 3 inputs (name, slug, order) all of them are required.

Note: Both methods return an instance of Folder eloquent instance.

It's so easy to delete a folder and all it's files.

After creating folders you can upload files/images into them using the MediaFile class.

Note: To upload files, you should be logged in, becuase the MediaFile class assigns auth()->id() to the user_id column in database,

but you can also upload files as guest by passing true in the second parameter, like so: new MediaFile($folder, true).

in this case it will assign 0 to the user_id column in database.

When you try to update an image (name, alt, title, caption) only the name is required.

The store and update methods returns an instance of Media eloquent instance, and you can update files like this:

It's so easy to delete a file as well.

You can upload image file from url using createUploadImageFromUrl() method:

You can also use it with laravel livewire by using livewireFile() method like this:

You can check if a file belongs to a folder like this:

Here's what you can get from Media eloquent instance.

Media eloquent instance has also some useful helpers (methods) for files/images, that you may need to use.

MediaFile Configurations

Now let's take a look at the config/mediafile.php file and what are the options available there.

Built-in Routes and Controllers

MediaFile offers a ready to go setup of routes and controllers that allows you to upload files and images without writing a single line of code.

Now you can access this feature by visiting /mediafiles in your app. for example: example.test/mediafiles.

You can also change the path name from /mediafiles to whatever path you want by passing path name to MediaFile::routes($path) method.

Now you can access this feature by visiting /media. for example: example.test/media.

The Media Folder

MediaFile allows you to create folders before you upload files into them, and by default the main folder called media and folders are being created in this path storage/app/public/media/.

You can change the name of the main folder media by changing the value of 'folder_name' in the config/mediafile.php file,

and if you want to create folders inside the public folder: storage/app/public/ directly wihtout a main folder you can do so by changing the value to null like his: 'folder_name' => null.

Image Encoder

Every uploaded image is gonna have an encoded version of it, and also encoded thumbnails with different sizes, the default encoded image data is webp.

But you can change it to whatever image format you perfer by changing the image_encoder value in the config/mediafile.php file.

To learn more about the supported formats check this link: https://image.intervention.io/v2/api/encode.

Image Thumbnails

Every uploaded image is gonna have 5 different encoded thumbnails with different sizes (1600w, 1200w, 900w, 600w, 300w).

You can customize the number of thumbnails and the width of each thumbnail in the config/mediafile.php file, by changing the value of image_thumbnail_sizes.

Image Thumbnail Separator

The default value of image_thumbnail_separator in the config/mediafile.php file is: _,

and it represent how you want to seperate between the name of the image and the size of the image thumbnail,

which means, If we upload an image named cat.png then the thumbnails of this image are gonna be named this way:

(cat_300.webp, cat_600.webp, cat_900.webp, etc..)

License

This package is released under the MIT license (MIT).


All versions of mediafile with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.2
intervention/image Version ^2.7
laravel/framework Version ^11.9
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 melsaka/mediafile contains the following files

Loading the files please wait ....