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: ^12.0||^13.0
- illuminate/http: ^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||^11.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
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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 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.
Proxy URLs, security and caching
When a pCloud disk has no url, the package serves its files through the application at /assets/<disk>/<path> (this is what url() and temporaryUrl() return). Optional disk keys:
'pcloud' => [ // ... 'visibility' => 'private', // only signed URLs (temporaryUrl) are served; default: public 'proxy_max_age' => 86400, // browser Cache-Control max-age for public files (seconds) 'proxy_metadata_ttl' => 300, // server-side cache of file metadata (seconds, 0 = disabled) 'verify_ssl' => true, // verify TLS when downloading from pCloud (keep enabled) ],
- A URL carrying a signature (
expires/signature) is always verified; a forged or stripped one gets a 403. - Paths containing
./..segments, backslashes or NUL bytes are rejected (404): a disk never reaches outside itsroot. - Responses carry
ETag,Last-ModifiedandCache-Control: browsers revalidate with a 304 without the file being downloaded from pCloud again. - Only types that cannot run scripts (images except SVG, PDF, audio/video, plain text) are rendered inline; anything else (SVG, HTML...) is sent as a download with
X-Content-Type-Options: nosniff.
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.