Download the PHP package alex-dwt/file without Composer
On this page you can find all versions of the php package alex-dwt/file. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alex-dwt/file
More information about alex-dwt/file
Files in alex-dwt/file
Package file
Short Description Files logic for Yii2 applications. Working with files as simple model attributes.
License
Homepage http://rgt.by/
Informations about the package file
Yii2 File Manager
Yii2 extension that allows to work with files as with simple properties.
Advantages
-
Usage of files like any other simple property.
-
Storages logic is separated and can be change without changing your controllers or views.
-
Formatters logic is separated. For each of file you can define formatters. This formatters allow to generate and use formatted versions of file. Added useful watermakr, thumb, grayscale and others formatters for images.
-
Useful getting url of source file or formatted version of file.
-
File storage allows to save origin file names.
-
Useful config for default file url (for dummy urls).
- You can use ajax file uploader with minimal application config.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json.
Usage
Example of usage for avatar field in ContactForm model:
-
Add contextManager application component config in your cfg file:
- Add flexibuild\file\ModelBehavior in your model. For example you have property $avatar in you model.
After that your model has property 'avatarFile'. It type is \flexibuild\file\File object. For better compability with IDE we recommend to add this property in your model's PHPDoc:
-
For adding possibility to change 'avatarFile' through 'setAttributes()' method, you must to add some rule or edit your scenarios() method. Example with 'rules()' method:
-
Add using one of the widgets in your view file. You can use ActiveFormEx or ActiveFieldEx (or FieldFileInputsTrait) for greater convenience.
- For using AJAX file uploader you must to add upload action in your controller map. For that you can use flexibuild\file\web\UploadAction in your controller or use flexibuild\file\web\UploadController with contexts config:
After that instead of SimpleFileInput you can use ajax jquery uploader:
OR
- You can use your new file property not only in form. In other your views you can:
See \flexibuild\file\File object for more info.
All versions of file with dependencies
yiisoft/yii2-imagine Version *
yiisoft/yii2-jui Version *
bower-asset/blueimp-file-upload Version *
flexibuild/component Version *