All Projects → 2amigos → yii2-flysystem-component

2amigos / yii2-flysystem-component

Licence: other
The League Flysystem Library for Yii Framework

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-flysystem-component

yii2-config-kit
Configuration kit for Yii applications
Stars: ✭ 24 (+9.09%)
Mutual labels:  yii2, 2amigos
yii2-grid-view-library
Highly enhanced GridView widget and grid components for Yii2
Stars: ✭ 57 (+159.09%)
Mutual labels:  yii2, 2amigos
yii2-multi-select-widget
Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
Stars: ✭ 45 (+104.55%)
Mutual labels:  yii2, 2amigos
yii2-switch-widget
Bootstrap Switch Widget for Yii2
Stars: ✭ 17 (-22.73%)
Mutual labels:  yii2, 2amigos
flysystem-sync
Filesystem sync using Flysystem project.
Stars: ✭ 26 (+18.18%)
Mutual labels:  flysystem
yii2-user
Flexible user registration and authentication module for Yii2.
Stars: ✭ 24 (+9.09%)
Mutual labels:  yii2
yii2-highlight
Yii2 Highlight.js extension
Stars: ✭ 14 (-36.36%)
Mutual labels:  yii2
yii2-fileapi-widget
Yii2 FileAPI widget.
Stars: ✭ 51 (+131.82%)
Mutual labels:  yii2
deruv
The elegant and professional PHP Content Management System
Stars: ✭ 38 (+72.73%)
Mutual labels:  yii2
yii2-rest-client
REST client (AR-like model) for Yii Framework 2.0 (via yii2-http-client)
Stars: ✭ 19 (-13.64%)
Mutual labels:  yii2
slides
Alexander Makarov conference slides
Stars: ✭ 26 (+18.18%)
Mutual labels:  yii2
yii2-formbuilder
A drag and drop form builder with jQuery for Yii2
Stars: ✭ 33 (+50%)
Mutual labels:  yii2
yii2-dysms
阿里云 dysms 官方 SDK 的 Composer 封装,支持 yii2 项目。
Stars: ✭ 13 (-40.91%)
Mutual labels:  yii2
yii2-actionbar
A control bar with bulk actions for the GridView widget.
Stars: ✭ 32 (+45.45%)
Mutual labels:  yii2
yii2-link-preview
LinkPreview widget render page preview
Stars: ✭ 26 (+18.18%)
Mutual labels:  yii2
yii2-js-urlmanager
That extension provide a way to create urls from your frontend part.
Stars: ✭ 53 (+140.91%)
Mutual labels:  yii2
flysystem-stream-wrapper
Provides the ability to register Flysystem filesystems as stream wrappers.
Stars: ✭ 59 (+168.18%)
Mutual labels:  flysystem
yii2-faker
Yii 2 Faker extension
Stars: ✭ 99 (+350%)
Mutual labels:  yii2
yii2-gtreetable
Extension of Yii 2 Framework, which is wrapper for bootstrap-gtreetable plugin, on the other hand it provides functionality which allows to save the nodes states into database.
Stars: ✭ 41 (+86.36%)
Mutual labels:  yii2
hisite
Hisite Yii2 base project
Stars: ✭ 15 (-31.82%)
Mutual labels:  yii2

Flysystem Component Wrappers for Yii 2

Latest Stable Version Software License Build Status Quality Score Total Downloads

Flysystem is a file system abstraction which allows you to easily swap out a local filesystem for a remote one.

This component library provides components that expose the Flysystem API to your Yii 2 applications. The following are the currently supported ones:

Install

The preferred way to install this extension is through composer.

Either run

$ composer require 2amigos/yii2-flysystem-component

or add

"2amigos/yii2-flysystem-component": "^1.0"

to the require section of your composer.json file.

Usage

AwsS3FsComponent

Install dependency

$ composer require league/flysystem-aws-s3-v3

Configure on the application components section:

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\AwsS3FsComponent',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'bucket' => 'your-bucket',
            'region' => 'your-region',
            // 'version' => 'latest',
            // 'baseUrl' => 'your-base-url',
            // 'prefix' => 'your-prefix',
            // 'options' => [],
        ],
    ],
];

When you application run, you will be able to use the component as:

Yii::$app->fs->read(....);

Check http://flysystem.thephpleague.com/api/ for all the methods available. Same methods for all adapters.

AzureFsComponent

First ensure the pear repository is added to your composer.json file:

"repositories": [
    {
        "type": "pear",
        "url": "http://pear.php.net"
    }
],

Then install the latest version of the plugin

$ composer require league/flysystem-azure

Configure on the application components section:

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\AzureFsComponent',
            'accountName' => 'your-account-name',
            'accountKey' => 'your-account-key',
            'container' => 'your-container',
        ],
    ],
];

DropboxFsComponent

Install dependency

$ composer require spatie/flysystem-dropbox

Configure on the application components section:

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\DropboxFsComponent',
            'token' => 'your-access-token',
            // 'prefix' => 'your-prefix',
        ],
    ],
];

FtpFsComponent

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'ftpFs' => [
            'class' => 'dosamigos\flysystem\FtpFsComponent',
            'host' => 'ftp.example.com',
            // 'port' => 21,
            // 'username' => 'your-username',
            // 'password' => 'your-password',
            // 'ssl' => true,
            // 'timeout' => 60,
            // 'root' => '/path/to/root',
            // 'permPrivate' => 0700,
            // 'permPublic' => 0744,
            // 'passive' => false,
            // 'transferMode' => FTP_TEXT,
        ],
    ],
];

GoogleCloudFsComponent

Install dependency

$ composer require cedricziel/flysystem-gcs

Configure on the application components section:

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\GoogleCloudFsComponent',
            'projectId' => 'your-project-id',
            'bucket' => 'your-bucket',
            // 'prefix' => 'your-prefix',
        ],
    ],
];

GridFSFsComponent

Install dependency

$ composer require league/flysystem-gridfs

Configure on the application components section:

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\GridFSFsComponent',
            'server' => 'mongodb://localhost:27017',
            'database' => 'your-database',
        ],
    ],
];

LocalFsComponent

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\LocalFsComponent',
            'path' => '@webroot/your-writable-folder-to-save-files',
        ],
    ],
];

MemoryFsComponent

Install dependency

$ composer require league/flysystem-memory

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\MemoryFsComponent',
        ],
    ],
];

NullFsComponent

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\NullFsComponent',
        ],
    ],
];

RackspaceFsComponent

Install dependency

$ composer require league/flysystem-rackspace

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\RackspaceFsComponent',
            'endpoint' => 'your-endpoint',
            'region' => 'your-region',
            'username' => 'your-username',
            'apiKey' => 'your-api-key',
            'container' => 'your-container',
            // 'prefix' => 'your-prefix',
        ],
    ],
];

SftpFsComponent

Install dependency

$ composer require league/flysystem-sftp

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\SftpFsComponent',
            'host' => 'sftp.example.com',
            'username' => 'your-username',
            'password' => 'your-password',
            'privateKey' => '/path/to/or/contents/of/privatekey',
            // 'port' => 22,
            // 'timeout' => 60,
            // 'root' => '/path/to/root',
            // 'permPrivate' => 0700,
            // 'permPublic' => 0744,
        ],
    ],
];

WebDAVFsComponent

Install dependency

$ composer require league/flysystem-webdav

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\WebDAVFsComponent',
            'baseUri' => 'your-base-uri',
            // 'userName' => 'your-user-name',
            // 'password' => 'your-password',
            // 'proxy' => 'your-proxy',
            // 'authType' => \Sabre\DAV\Client::AUTH_BASIC,
            // 'encoding' => \Sabre\DAV\Client::ENCODING_IDENTITY,
            // 'prefix' => 'your-prefix',
        ],
    ],
];

ZipArchiveFsComponent

Install dependency

$ composer require league/flysystem-ziparchive

Configure application components as follows

return [
    //...
    'components' => [
        //...
        'fs' => [
            'class' => 'dosamigos\flysystem\ZipArchiveFsComponent',
            'path' => '@webroot/files/archive.zip',
            // 'prefix' => 'your-prefix',
        ],
    ],
];

Cool Stuff

Multiple Instances

You can configure as many components as you need. Simply add them to the components section with different names. For example, I could have S3 and FTP at the same time:

return [
    //...
    'components' => [
        //...
        's3Fs' => [
            'class' => 'dosamigos\flysystem\AwsS3FsComponent',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'bucket' => 'your-bucket',
            'region' => 'your-region',
            // 'version' => 'latest',
            // 'baseUrl' => 'your-base-url',
            // 'prefix' => 'your-prefix',
            // 'options' => [],
        ],
        'ftpFs => [
            'class' => 'dosamigos\flysystem\FtpFsComponent',
            'host' => 'ftp.example.com',
        ]
    ],
];

Now, I could use them like Yii::$app->s3Fs and Yii::$app->ftpFs respectively.

Caching

If you wish to add caching functionality, first we need to include the dependencies on your composer.json file:

$ composer require league/flysystem-cached-adapter

Next, configure the following attributes on your adapter:

return [
 //...
 'components' => [
     //...
     'fs' => [
         //...
         'cache' => 'cacheID',
         // 'cacheKey' => 'my-cache-key',
         // 'cacheDuration' => 7200,
     ],
 ],
];

Replicating

The replication facilitates transitions between adapters, allowing an application to stay functional and migrate its files from one adapter to another. The adapter takes two other adapters, a source and a replica. Every change is delegated to both adapters, while all the read operations are passed onto the source only.

To use the replication feature first install its dependencies:

$ composer require league/flysystem-replicate-adapter

Next, configure as follows:

return [
    //...
    'components' => [
        //...
        's3Fs' => [
            'class' => 'dosamigos\flysystem\AwsS3FsComponent',
            'key' => 'your-key',
            'secret' => 'your-secret',
            'bucket' => 'your-bucket',
            'region' => 'your-region',
        ],
        'ftpFs => [
            'class' => 'dosamigos\flysystem\FtpFsComponent',
            'host' => 'ftp.example.com',
            'replica' => 's3Fs' // we have added the ID of the replica component
        ]
    ],
];

Further Information

Testing

$ phpunit

Using code fixer

We have added a PHP code fixer to standardize our code. It includes Symfony, PSR2 and some contributors rules.

./vendor/bin/php-cs-fixer fix ./src --config .php_cs

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.


Custom Software | Web & Mobile Software Development
www.2amigos.us
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].