Download the PHP package floor12/yii2-module-files without Composer

On this page you can find all versions of the php package floor12/yii2-module-files. 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 yii2-module-files

yii2-module-files

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

Этот файл доступен на русском языке.

About the module

FileInputWidget

This module was designed to solve the problem of creating file fields in ActiveRecord models of the Yii2 framework. The main components of the module are:

Key features

i18n

At this stage, the module supports the following languages:

Principle of operation

All files data is stored in the file table. The file model relay to the model by three fields:

When file added to the form, it uploads to server in background where all processing takes place. As a result of this processing, it is written to disk and a new entry is created for it in the file table, with the fieldsclass and field filled with data from the model, andobject_id is empty and will assign only after saving the ActiveRecord model. When a file is deleted from the widget, it is not deleted from the disk and the file table, just obejct_id equals to 0. You can use the console commandfiles / console / clean to periodically clean up this kind of orphan files.

Install and setup

To add this module to your app, just run:

or add this to the require section of your composer.json.

Then execute a migration to create file table.

After that, include module data in modules section of application config:

Parameters to set:

Usage

Work with ActiveRecord Model

To add one or more files fields to the ActiveRecord model, you need to connect floor12\files\components\FileBehaviour to it and pass list the field names that will store the files in the model. For example, for the User model, 2 file fields are defined here : avatar anddocuments:

To have nice attribute labels in forms, add some labels to attributeLabels():

Setup validation rules in the rules() method of ActiveRecord model:

Work with files

If maxFiles in FileValidator equals to 1, this attribute will store an floor12\files\models\File object. Example:

If the file is image, getPreviewWebPath method returns a web path to image thumbnail. By default thumbnail created with the jpeg or png format, it depends to source file. But also WEBP option is available.

File::getPreviewWebPath(int $width = 0, int $height = 0 ,bool $webp = false)

Usage example:

When maxFiles equals to 1, multiple upload is available. In this case, model field will contains an array if floor12\files\models \File objects:

Here is another example, the advanced usage of thumbnails. In this case, we use modern picture andsource tags, as well as media queries. As a result, we have 8 different thumbnails: 4 has webp format for those browsers that support this it, and 4 has jpeg format. Devices with retina displays will get an images with double resolution, regular screens have regular sized pictures. This example also uses different images widths at different screen widths (just as example of mobile/desktop image switching):

Picture tag widget

If object if tyle File is image ($file->isImage() === true), it can be used with PictureWidget. This widget helps generate html tag with srcset with 2x and webp versions. For example this code:

will make this html:

Additional parameters allowed to pass media-queries to widget.

Listing the files

There is a widget for listing all files. It supports Lightbox2 gallery to display images and MS Office files preview. Its also supports downloading of the all the files attached to the field in a ZIP-archive.

An array of File objects must be passed to the widget files field. Also additional parameters available:

FileInputWidget

InputWidget for ActiveFrom

To display files block in your forms use the floor12\files\components\FileInputWidget:

Moreover, if maxFiles parameter inFileValidator equals to 1 or more, FileInputWidget will take the necessary form to load one file or several at once. If necessary, you can pass uploadButtonText anduploadButtonClass parameters to the widget.

Contributing

I will be glad of any help in the development, support and bug reporting of this module.


All versions of yii2-module-files with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
yiisoft/yii2 Version ^2.0.
ext-gd Version *
ext-zip Version *
ext-exif Version *
yiisoft/yii2-jui Version *
yii2mod/yii2-enum Version ^1.7
floor12/yii2-notification Version *
bower-asset/cropper Version *
bower-asset/lightbox2 Version *
bower-asset/simple-ajax-uploader Version >=2.6.7
ext-fileinfo Version *
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 floor12/yii2-module-files contains the following files

Loading the files please wait ....