PHP code example of leobsst / laravel-pcloud-filesystem

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

    

leobsst / laravel-pcloud-filesystem example snippets


'disks' => [
    // ...existing disks...

    'pcloud' => [
        'driver'       => 'pcloud',
        'access_token' => env('PCLOUD_ACCESS_TOKEN'),
        'location_id'  => env('PCLOUD_LOCATION_ID', 1),
        'root'         => env('PCLOUD_ROOT', '/'),
    ],
],

'pcloud-backup' => [
    'driver'       => 'pcloud',
    'access_token' => env('BACKUP_PCLOUD_ACCESS_TOKEN'),
    'location_id'  => env('BACKUP_PCLOUD_LOCATION_ID', 1),
    'root'         => env('BACKUP_PCLOUD_ROOT', '/'),
],

use Illuminate\Support\Facades\Storage;

// Write a file
Storage::disk('pcloud')->put('hello.txt', 'Hello, pCloud!');

// Write from a stream
Storage::disk('pcloud')->writeStream('video.mp4', fopen('/path/to/video.mp4', 'rb'));

// Check existence
Storage::disk('pcloud')->exists('hello.txt');       // true
Storage::disk('pcloud')->directoryExists('photos'); // true

// Read a file
$contents = Storage::disk('pcloud')->get('hello.txt');

// Read as a stream
$stream = Storage::disk('pcloud')->readStream('video.mp4');

// List contents (non-recursive)
$files = Storage::disk('pcloud')->files('photos');

// List contents recursively
$all = Storage::disk('pcloud')->allFiles('photos');

// Move / rename
Storage::disk('pcloud')->move('hello.txt', 'archive/hello.txt');

// Copy
Storage::disk('pcloud')->copy('hello.txt', 'backup/hello.txt');

// Delete a file
Storage::disk('pcloud')->delete('hello.txt');

// Delete a directory and its contents
Storage::disk('pcloud')->deleteDirectory('archive');

// Create a directory
Storage::disk('pcloud')->makeDirectory('new-folder');

// File metadata
Storage::disk('pcloud')->size('video.mp4');
Storage::disk('pcloud')->lastModified('video.mp4');
Storage::disk('pcloud')->mimeType('video.mp4');
bash
php artisan pcloud-filesystem:install
bash
php artisan pcloud-filesystem:configure
bash
php artisan pcloud-filesystem:configure
# prefix: BACKUP