Download the PHP package diecoding/yii2-flysystem without Composer
On this page you can find all versions of the php package diecoding/yii2-flysystem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-flysystem
Yii2 Flysystem
The League Flysystem for local and remote filesystems library for Yii2.
This extension provides Flysystem 3 integration for the Yii framework. Flysystem is a filesystem abstraction which allows you to easily swap out a local filesystem for a remote one.
Yii2 Flysystem uses league/flysystem
Table of Contents
- Yii2 Flysystem
- Table of Contents
- Instalation
- Dependencies
- Dev. Dependencies
- Configuration
- Local Filesystem
- AsyncAws S3 Filesystem
- AWS S3 Filesystem
- Google Cloud Storage Filesystem
- FTP Filesystem
- SFTP Filesystem
- WebDAV Filesystem
- ZipArchive Filesystem
- Google Drive Filesystem
- Additional Configuration
- URL File Action Settings
- Global Visibility Settings
- Usage
- Writing or Updating Files
- Reading Files
- Checking if a File Exists
- Deleting Files
- Getting Files Mime Type
- Getting Files Timestamp / Last Modified
- Getting Files Size
- Creating Directories
- Checking if a Directory Exists
- Deleting Directories
- Checking if a File or Directory Exists
- Managing Visibility
- Listing contents
- Copy Files or Directories
- Move Files or Directories
- Get URL Files
- Get URL Temporary Files / Presigned URL
- Get MD5 Hash File Contents
- Using Traits
- Model Trait
- Using Trait Methods
- Overriding Trait Methods
- getFsComponent
- attributePaths
- getPresignedUrlDuration
Instalation
Package is available on Packagist, you can install it using Composer.
or add to the require section of your composer.json
file.
Dependencies
Dev. Dependencies
- league/flysystem-async-aws-s3
- league/flysystem-aws-s3-v3
- league/flysystem-google-cloud-storage
- league/flysystem-ftp
- league/flysystem-sftp-v3
- league/flysystem-webdav
- league/flysystem-ziparchive
- masbug/flysystem-google-drive-ext
Configuration
Local Filesystem
Configure application components
as follows
AsyncAws S3 Filesystem
See: league/flysystem-async-aws-s3
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
AWS S3 Filesystem
See: league/flysystem-aws-s3-v3
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
Google Cloud Storage Filesystem
See: league/flysystem-google-cloud-storage
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
FTP Filesystem
See: league/flysystem-ftp
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
SFTP Filesystem
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
WebDAV Filesystem
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
ZipArchive Filesystem
See: league/flysystem-ziparchive
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
Google Drive Filesystem
See: masbug/flysystem-google-drive-ext
Either run
or add
to the require
section of your composer.json
file and configure application components
as follows
Additional Configuration
URL File Action Settings
The following adapters have URL File Action generation capabilities:
- Local Component
- FTP Component
- SFTP Component
- Google Drive Component
Configure action
in controller
as follows
This example at
SiteController
for/site/file
Remember to configure
action
key infs
application components as follows
Global Visibility Settings
Configure fs
application component as follows
Usage
Writing or Updating Files
To write or update file
To write or update file using stream contents
Reading Files
To read file
To retrieve a read-stream
Checking if a File Exists
To check if a file exists
Deleting Files
To delete file
Getting Files Mime Type
To get file mime type
Getting Files Timestamp / Last Modified
To get file timestamp
Getting Files Size
To get file size
Creating Directories
To create directory
Directories are also made implicitly when writing to a deeper path
Checking if a Directory Exists
To check if a directory exists
Deleting Directories
To delete directory
Checking if a File or Directory Exists
To check if a file or directory exists
Managing Visibility
Visibility is the abstraction of file permissions across multiple platforms. Visibility can be either public or private.
You can also change and check visibility of existing files
Listing contents
To list contents
By default Flysystem lists the top directory non-recursively. You can supply a directory name and recursive boolean to get more precise results
Copy Files or Directories
To copy contents
Move Files or Directories
To move contents
Get URL Files
To get url contents
Get URL Temporary Files / Presigned URL
To get temporary url contents
The $expiresAt
should be a valid and instance of PHP DateTimeInterface
. Read PHP documentation for details.
Get MD5 Hash File Contents
To get MD5 hash of the file contents
Using Traits
Model Trait
Attach the Trait to the Model/ActiveRecord
with some media attribute that will be saved in Flysystem (fs):
Override the attributePaths()
method to change the base path where the files will be saved on Flysystem (fs).
- You can map a different path to each file attribute of your
Model/ActiveRecord
.
Using Trait Methods
Overriding Trait Methods
getFsComponent
The Flysystem (fs) MediaTrait depends on this component to be configured. The default configuration is to use this component on index 'fs'
, but you may use another value. For this cases, override the getFsComponent()
method:
attributePaths
The main method to override is attributePaths()
, which defines a path in Flysystem (fs) for each attribute of yout model. Allowing you to save each attribute in a different Flysystem (fs) folder.
Here an example:
getPresignedUrlDuration
The default pressigned URL duration is set to "+5 Minutes", override this method and use your own expiration.
Return must instance of DateTimeInterface
The value should be a valid and instance of PHP DateTimeInterface
. Read PHP documentation for details.
Read more docs: https://sugengsulistiyawan.my.id/docs/opensource/yii2/flysystem/
All versions of yii2-flysystem with dependencies
league/flysystem Version ^3.0
league/flysystem-path-prefixing Version ^3.0
yiisoft/yii2 Version ~2.0