leobsst / laravel-pcloud-filesystem
File system pCloud PHP SDK integration for Laravel-based application.
Package info
github.com/leobsst/laravel-pcloud-filesystem
pkg:composer/leobsst/laravel-pcloud-filesystem
Fund package maintenance!
Requires
- php: ^8.2
- illuminate/contracts: ^11.0||^12.0||^13.0
- illuminate/http: ^11.0||^12.0||^13.0
- league/flysystem: ^3.0
- pcloud/pcloud-php-sdk: ^3.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^3.0||^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
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:
- Ask for an optional environment variable prefix (e.g.
BACKUP→BACKUP_PCLOUD_ACCESS_TOKEN). Leave empty for the defaultPCLOUD_*names. - Ask for your pCloud client_id and client_secret (obtained from the pCloud developer console).
- Open a browser authorization URL — after you approve, copy the
codefrom the redirect URL. - Exchange the code for an access token and write
PCLOUD_ACCESS_TOKEN,PCLOUD_LOCATION_ID, andPCLOUD_ROOTto 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.