PHP code example of kcs / filesystem

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

    

kcs / filesystem example snippets


use Kcs\Filesystem\Local\LocalFilesystem;

$fs = new LocalFilesystem('/var/app/storage');
$fs->write('hello.txt', 'Hello!');
$contents = $fs->read('hello.txt')->read(1024);

use AsyncAws\S3\S3Client;
use Kcs\Filesystem\AsyncS3\AsyncS3Filesystem;

$client = new S3Client([
    'region' => 'eu-west-1',
    'accessKeyId' => '...',
    'accessKeySecret' => '...',
]);

$fs = new AsyncS3Filesystem('my-bucket', '/', $client);
$fs->write('path/file.txt', 'content');

use Google\Cloud\Storage\StorageClient;
use Kcs\Filesystem\GCS\GCSFilesystem;

$client = new StorageClient([
    'projectId' => 'my-project',
    'keyFilePath' => '/path/to/credentials.json',
]);

$fs = new GCSFilesystem('my-bucket', '/', $client);
$fs->write('path/file.txt', 'content');