PHP code example of arhitector / yandex-disk-flysystem

1. Go to this page and download the library: Download arhitector/yandex-disk-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/ */

    

arhitector / yandex-disk-flysystem example snippets


public __construct(Disk $client [, $prefix = 'disk:/'])

// set a token before creation of the adapter
$client = new Arhitector\Yandex\Disk([string $accessToken]);

// or
$client->setAccessToken(string $accessToken);

// create adapter
$adapter = new Arhitector\Yandex\Disk\Adapter\Flysystem($client);

// or with app folder
$adapter = new Arhitector\Yandex\Disk\Adapter\Flysystem($client, Arhitector\Yandex\Disk\Adapter\Flysystem::PREFIX_APP);

// create Filesystem
$filesystem = new League\Flysystem\Filesystem($adapter);

// and use
$contents = $filesystem->listContents();

var_dump($contents);

$filesystem->write('path', 'contents', [
    'events' => [
        'event-name 1' => 'listener', /* function, etc. */
        'event-name 2' => 'other listener'
    ]
]);

$filesystem->write('path', 'contents', [
    'events' => [
        'event-name' => [
            'listener 1' /* function, etc. */,
            'listener 2' /* function, etc. */,
            'listener 3' /* function, etc. */
        ]
    ]
]);