Download the PHP package pcloud/pcloud-php-sdk without Composer

On this page you can find all versions of the php package pcloud/pcloud-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pcloud-php-sdk

pCloud SDK for PHP

A PHP library to access pCloud API


Table of Contents


System requirements

PHP 7.1.0 or higher is Required

  Likelihood Of Impact: Critical

Get started

Register your application

In order to use this SDK, you have to register your application in My applications.


Install the SDK

Using Composer

Install Composer.

or add the following to composer.json file

"require": {
  "pcloud/pcloud-php-sdk": "3.*"
}

Manually

Copy lib/ folder and include lib/autoload.php in your code


Initializing the SDK

The SDK uses an OAuth 2.0 access token to authorize requests to the pCloud API. You can obtain a token using the SDK's authorization flow. To allow the SDK to do that, find App Key, App secret and Redirect URIs in your application configuration page and add them to /example/code.php and /example/auth.php.

Note that redirect_uri is optional.

Run /example/code.php to get an authorization code and use this code in /example/auth.php. This will return access_token and locationid.


Example

// Include autoload.php and set the credential file path

$access_token = "ACCESS_TOKEN";
$locationid = 1;

$pCloudApp = new pCloud\Sdk\App();
$pCloudApp->setAccessToken($access_token);
$pCloudApp->setLocationId($locationid);

// Create Folder instance

$pcloudFolder = new pCloud\Sdk\Folder($pCloudApp);

// Create new folder in root

$folderId = $pcloudFolder->create("New folder");

// Create File instance

$pcloudFile = new pCloud\Sdk\File($pCloudApp);

// Upload new file in created folder

$fileMetadata = $pcloudFile->upload("./sample.png", $folderId);

// Get folder content

$folderContent = $pcloudFolder->getContent($folderId);

Creating custom requests

$access_token = "";
$locationid = 1;

$pCloudApp = new pCloud\Sdk\App();
$pCloudApp->setAccessToken($access_token);
$pCloudApp->setLocationId($locationid);

$method = "userinfo";
$params = array();

$request = new pCloud\Sdk\Request($pCloudApp);
$response = $request->get($method, $params); // the second argument is optional

Migration guide

In version SDK version 3 the most significant changes are related to adjusting the namespaces. To easily migrate to version 3 you need to change the following:

<?php 

namespace MyPhpApplication;

# this
use pCloud\App; // <-- Old versions

# change to: 
use pCloud\Sdk\App;  // <-- version 3.

-----

The same change needs to be applied to all pCloud SDK names, pCloud\File, pCloud\Folder, ...

In case you intanciating the classes directly, you can make the following changes:

<?php 

namespace MyPhpApplication;

# this
$pCloudFolder = new pCloud\Folder($pCloudApp); // <-- Old versions

# change to: 
$pCloudFolder = new pCloud\Sdk\Folder($pCloudApp); // <-- version 3.

-----

In case we missed something, you can find more examples in the "example" folder.


All versions of pcloud-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pcloud/pcloud-php-sdk contains the following files

Loading the files please wait ....