Download the PHP package itstructure/laravel-media-file-uploader without Composer

On this page you can find all versions of the php package itstructure/laravel-media-file-uploader. 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-media-file-uploader

Laravel Media File Uploader - MFU

Latest Stable Version Latest Unstable Version License Total Downloads Build Status Scrutinizer Code Quality

1 Introduction

This package is to upload different media files to Local or remote Amazon S3 storage.

MFU logotip

2 Requirements

3 Installation

3.1 Install package

General from remote Packagist repository

Run the composer command:

composer require itstructure/laravel-media-file-uploader "^1.0.3"

If you are testing this package from a local server directory

In application composer.json file set the repository, as in example:

Here,

../laravel-media-file-uploader - directory path, which has the same directory level as application and contains MFU package.

Then run command:

composer require itstructure/laravel-media-file-uploader:dev-main --prefer-source

3.3 Publish files - Required part

3.4 Publish files - Custom part

3.5 Publish files - All parts if needed

3.6 Run migrations

php artisan migrate

4 Configure

4.1 Set default filesystem disk

In a config file filesystems.php set the next custom settings (set default disk which you wish) and create needed base upload folder:

Run command to create symbolic links:

php artisan storage:link

4.2 Set assets

Pay Attention! This option is needed just in the next cases:

Make sure you use a Bootstrap 4 for styling and JQuery in your application.

4.2.1 Custom body layout case

So, set the next css assets between head tags of your app layout:

Set the next js asset at the end of the body tag of your app layout:

Note: vendor/uploader/js/jquery.min.js is required just if JQuery is absent in your application.

4.2.2 If you use AdminLTE package in your project

Pay attention: Not recommended using of asset() in AdminLTE config file, because it may cause an error with UrlGenerator.php when you will run fore example composer install later.

4.3 Change uploader.php config file.

This file is intuitive.

But at this stage, pay attention to the next important options:

5 Usage

5.1 Routes part

There are already integrated base MFU routes to manage files and albums. See in routes/uploader.php package file.

The next routes are available by default:

E.t.c... See in routes/uploader.php package file the next albums routes for Excel, Visio, PowerPoint, PDF, Text, Other albums. They have similar principle.

Album editor POST request method fields are equal for all albums:

5.2 Easy quick way

5.2.1 Access to File list manager

MFU file list manager

5.2.2 Access to File upload manager

If to click on green Uploader button in a file list manager, you will go to uploader_file_upload_manager route: http://example-domain.com/uploader/managers/file-upload.

MFU file upload manager

5.2.3 Access to File edit manager

If to click on green edition button in a file list manager, you will go to uploader_file_edit_manager route: http://example-domain.com/uploader/managers/file-edit/{id}:

MFU file edit manager

5.2.4 Access to Media file preview

If you have got a media file entry $mediaFile by Itstructure\MFU\Models\Mediafile model entity:

Here you can use some of the next options:

\Itstructure\MFU\Services\Previewer::LOCATION_FILE_ITEM \Itstructure\MFU\Services\Previewer::LOCATION_FILE_INFO \Itstructure\MFU\Services\Previewer::LOCATION_EXISTING

5.2.5 Download Media file

Use route:

5.2.6 Access to Album Editor

Simply use albums routes, described above in Album editor section of 5.1 Routes part.

But pay attention! You must set a layout for album editor:

Value adminlte::page is for case if you use AdminLTE. Or you can set your special layout.

Image album list example looks like this:

MFU album list

Image album edition page example looks like this:

MFU album edit

5.3 Digging deeper

5.3.1 Data base structure

MFU db

5.3.2 Short architecture structure and request way for uploading process in simple words

  1. Call UploadController method.
  2. Call static method from Itstructure\MFU\Facades\Uploader facade in controller method.
  3. Get instance of Uploader service Itstructure\MFU\Services\Uploader::getInstance($config) and call here a facade's method.
  4. Get instance of needed processor, with set config data from service to this:

    Itstructure\MFU\Processors\UploadProcessor or

    Itstructure\MFU\Processors\UpdateProcessor or

    Itstructure\MFU\Processors\DeleteProcessor.

  5. Set process parameters and then call it's run() method.

See inside core.

5.3.3 Use FileSetter

FileSetter is needed to set file id in to the form field and file preview to special container before sending request to controller during saving some entity: Page, Catalog, Product e.t.c.

Example FileSetter using for thumbnail:

Visually it looks like that:

MFU file setter

If to click on Set thumbnail button, then file list manager will be opened, but with additional button "V":

MFU file list with file setter button

This button is to choose a concrete file and insert it's preview in to the thumbnail_container and it's ID in to the automatically rendered form field by attribute option.

See next point 5.3.4 to understand how this selected file can be linked with a parent owner, like for example: Page, Product e.t.c...

5.3.4 Link media files with parent owner

For example you use Product eloquent model, which contains albums and media files both.

Albums and media files can be linked with Product, after Product is saved, through owners_albums and owners_mediafiles DB relations.

This relations are set by BehaviorMediafile and BehaviorAlbum classes automatically.

The main rules:

See deeper in to core and imagine how it works :-)

Go next...

It is very important to use MFU blade partials correctly in your application blade forms!

Short cut example for the blade form with using

uploader::partials.thumbnail,

uploader::partials.new-mediafiles,

uploader::partials.existing-mediafiles,

uploader::partials.albums-form-list:

To clarify:

By fileType there will be set a field image[], which will be set by fill() method in Itstructure\MFU\Traits\OwnerBehavior trait using getBehaviorAttributes(), and then it's value will be put in to the BehaviorMediafile object during booted() calling after for example Product is saved. Then a table owners_mediafiles will be filled. Link between Product and Mediafile will be created.

Product edition page example looks like this:

MFU product edit

To see more, how that example works in global, see real example here: Laravel Microshop Simple.

I hope you will be happy with this package. Good luck with your development!

With all respect, Andrey!

License

Copyright © 2024 Andrey Girnik [email protected].

Licensed under the MIT license. See LICENSE.txt for details.


All versions of laravel-media-file-uploader with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
laravel/framework Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
itstructure/laravel-grid-view Version ^1.1.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 itstructure/laravel-media-file-uploader contains the following files

Loading the files please wait ....