leobsst/laravel-pcloud-filesystem 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

leobsst/laravel-pcloud-filesystem

Composer 安装命令:

composer require leobsst/laravel-pcloud-filesystem

包简介

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

README 文档

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.

统计信息

  • 总下载量: 505
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固