PHP code example of airani / yii2-flysystem

1. Go to this page and download the library: Download airani/yii2-flysystem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

airani / yii2-flysystem example snippets


return [
    // ...
    'componenets' => [
        // ...
        'flysystem' => [
            'class' => 'airani\flysystem\MountManager',
            'localFs' => [ // https://flysystem.thephpleague.com/adapter/local/
                'class' => 'League\Flysystem\Adapter\Local',
                'root' => __DIR__.'/path/to/too',
            ],
            'ftpFs' => [ // https://flysystem.thephpleague.com/adapter/ftp/
                'class' => 'League\Flysystem\Adapter\Ftp',
                'config' => [
                    'host' => 'ftp.example.com',
                    'username' => 'username',
                    'password' => 'password',

                    // optional config settings
                    'port' => 21,
                    'root' => '/path/to/root',
                    'passive' => true,
                    'ssl' => true,
                    'timeout' => 30,
                ],
            ],
            // and config other filesystem adapters
            // read adapters section of flysystem guide https://flysystem.thephpleague.com
        ],
    ],
];

// Read from FTP
$contents = Yii::$app->flysystem->read('ftp://some/file.txt');

// And write to local
Yii::$app->flysystem->write('local://put/it/here.txt', $contents);

Yii::$app->filesystem->localFs->write('path/to/file.txt', 'contents');