leobsst/laravel-pcloud-filesystem

File system pCloud PHP SDK integration for Laravel-based application.

Maintainers

Package info

github.com/leobsst/laravel-pcloud-filesystem

pkg:composer/leobsst/laravel-pcloud-filesystem

Fund package maintenance!

LEOBSST

Statistics

Installs: 139

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.7 2026-04-26 12:07 UTC

This package is auto-updated.

Last update: 2026-04-26 12:09:49 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads License Laravel PHP

A Laravel filesystem driver for pCloud, built on top of the pCloud PHP SDK and Flysystem v3. Exposes a pcloud disk driver that integrates seamlessly with Storage::disk('pcloud').

Requirements

  • PHP 8.2+
  • Laravel 11, 12, or 13

Installation

Install the package via Composer:

composer require leobsst/laravel-pcloud-filesystem

The service provider is auto-discovered — no manual registration needed.

Configuration

Option A — Interactive setup (recommended)

Run the install command. It will guide you through the OAuth2 flow and write the credentials directly to your .env:

php artisan pcloud-filesystem:install

Or run the configure command standalone (useful when adding a second pCloud disk with a prefix):

php artisan pcloud-filesystem:configure

The command will:

  1. Ask for an optional environment variable prefix (e.g. BACKUPBACKUP_PCLOUD_ACCESS_TOKEN). Leave empty for the default PCLOUD_* names.
  2. Ask for your pCloud client_id and client_secret (obtained from the pCloud developer console).
  3. Open a browser authorization URL — after you approve, copy the code from the redirect URL.
  4. Exchange the code for an access token and write PCLOUD_ACCESS_TOKEN, PCLOUD_LOCATION_ID, and PCLOUD_ROOT to your .env. If a variable already exists you will be asked whether to override it.

Option B — Manual setup

1. Obtain a pCloud access token

Create an app in the pCloud developer console and complete the OAuth2 flow to obtain an access token.

2. Add environment variables

PCLOUD_ACCESS_TOKEN=your-access-token-here
PCLOUD_LOCATION_ID=1     # 1 = US servers, 2 = EU servers
PCLOUD_ROOT=/            # Optional: root folder for all operations

3. Register the disk

Add the pcloud entry to the disks array in config/filesystems.php:

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

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

Multiple disks / prefix

If you need more than one pCloud disk (e.g. a primary and a backup), run pcloud-filesystem:configure a second time and supply a prefix when prompted:

php artisan pcloud-filesystem:configure
# prefix: BACKUP

This produces BACKUP_PCLOUD_ACCESS_TOKEN, BACKUP_PCLOUD_LOCATION_ID, and BACKUP_PCLOUD_ROOT, which you then wire up as a second disk in config/filesystems.php:

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

The root option scopes all filesystem operations to that pCloud folder. For example, setting root to /MyApp means Storage::disk('pcloud')->put('uploads/file.txt', ...) will write to /MyApp/uploads/file.txt on pCloud. Missing intermediate directories are created automatically.

Usage

Once configured, use the disk exactly like any other Laravel filesystem disk:

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');

Unsupported features

Visibility control is not supported by pCloud. Calling setVisibility() always throws UnableToSetVisibility. The visibility() method always returns public.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

Please see SECURITY for how to report security vulnerabilities.

Credits

License

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