PHPackages                             dmhendricks/b2-sdk-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. dmhendricks/b2-sdk-php

ActiveLibrary[File &amp; Storage](/categories/file-storage)

dmhendricks/b2-sdk-php
======================

A PHP SDK for Backblaze's B2 storage service.

1.3.4(7y ago)218911MITPHPPHP &gt;=5.6.4

Since Feb 17Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dmhendricks/b2-sdk-php)[ Packagist](https://packagist.org/packages/dmhendricks/b2-sdk-php)[ Docs](https://github.com/dmhendricks/b2-sdk-php)[ RSS](/packages/dmhendricks-b2-sdk-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (5)Versions (16)Used By (1)

[![GitHub License](https://camo.githubusercontent.com/07a7d0169027aac6d7a0bfa8964dfef5fbc40d5a2075cabb3d8bc67e17be3451/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f772e737667)](https://raw.githubusercontent.com/dmhendricks/wordpress-base-plugin/master/LICENSE)[![Latest Version](https://camo.githubusercontent.com/b9a89f7356bb012852858190313c9d72c02c80c1bfa05931837084e034d4a36c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f646d68656e647269636b732f62322d73646b2d7068702e737667)](https://github.com/dmhendricks/b2-sdk-php/releases)[![Packagist](https://camo.githubusercontent.com/12eb2ea25415b6e7121b05b078dc0c43419e5740213a637ce91377a69b46002b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646d68656e647269636b732f62322d73646b2d7068702e737667)](https://packagist.org/packages/dmhendricks/b2-sdk-php)[![Build Status](https://camo.githubusercontent.com/f644f1cec8272b86fc3297563ca51a9414be30bf3a6a6884867b94bac2273023/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63776869746539322f62322d73646b2d7068702e737667)](https://travis-ci.org/cwhite92/b2-sdk-php)[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://paypal.me/danielhendricks)[![WP Engine](https://camo.githubusercontent.com/c52967dd3e8628ed2d63b94e01d387136c8ee4331dee4d49d105b5f86141b541/68747470733a2f2f663030312e6261636b626c617a6562322e636f6d2f66696c652f68656e647269636b732f696d616765732f62616467652f7770656e67696e652e737667)](http://bit.ly/WPEnginePlans)[![Twitter](https://camo.githubusercontent.com/c58b6706d86634840a0508a0ee9069103e10c040821f6bc2bc2684bdfed0cab0/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f68747470732f6769746875622e636f6d2f646d68656e647269636b732f776f726470726573732d626173652d706c7567696e2e7376673f7374796c653d736f6369616c)](https://twitter.com/danielhendricks)

Backblaze B2 SDK for PHP
========================

[](#backblaze-b2-sdk-for-php)

`b2-sdk-php` is a client library for working with Backblaze's B2 storage service. It aims to make using the service as easy as possible by exposing a clear API and taking influence from other SDKs that you may be familiar with.

Authorization requests will be cached for 1 hour to avoid hitting the B2 API limit.

### History &amp; Changes

[](#history--changes)

This is a fork of the [RunCloudIO](https://github.com/RunCloudIO/b2-sdk-php) version, based on the original by [Chris White](https://github.com/cwhite92/b2-sdk-php), with the following changes:

- Implemented support for [b2\_list\_file\_versions](https://www.backblaze.com/b2/docs/b2_list_file_versions.html) from [ryanall](https://github.com/ryanall/b2-sdk-php/commit/4c3f5274e7ee2b72ad847dc2ebc3178ac71545d2) fork.
- `Client->download()` returns null on failure rather than invalid path.

Installation
------------

[](#installation)

To install via Composer:

```
composer require dmhendricks/b2-sdk-php

```

Usage Examples
--------------

[](#usage-examples)

```
use ChrisWhite\B2\Client;
use ChrisWhite\B2\Bucket;

$client = new Client('accountId', 'applicationKey');

// Returns the base B2 file URL
$client->getDownloadUrl();

// Returns the provided bucket/file prefixed with the B2 base URL
$client->getDownloadUrl([
    'BucketName' => 'my-special-bucket',
    'FileName' => 'path/to/file'
]);

// Returns a Bucket object.
$bucket = $client->createBucket([
    'BucketName' => 'my-special-bucket',
    'BucketType' => Bucket::TYPE_PRIVATE // or TYPE_PUBLIC
]);

// Change the bucket to private. Also returns a Bucket object.
$updatedBucket = $client->updateBucket([
    'BucketId' => $bucket->getId(),
    'BucketType' => Bucket::TYPE_PUBLIC
]);

// Retrieve an array of Bucket objects on your account.
$buckets = $client->listBuckets();

// Delete a bucket.
$client->deleteBucket([
    'BucketId' => '4c2b957661da9c825f465e1b'
]);

// Upload a file to a bucket. Returns a File object.
$file = $client->upload([
    'BucketName' => 'my-special-bucket',
    'FileName' => 'path/to/upload/to',
    'Body' => 'I am the file content'

    // The file content can also be provided via a resource.
    // 'Body' => fopen('/path/to/input', 'r')
]);

// Download a file from a bucket. Returns the file content.
$fileContent = $client->download([
    'FileId' => $file->getId()

    // Can also identify the file via bucket and path:
    // 'BucketName' => 'my-special-bucket',
    // 'FileName' => 'path/to/file'

    // Can also save directly to a location on disk. This will cause download() to not return file content.
    // 'SaveAs' => '/path/to/save/location'
]);

// Delete a file from a bucket. Returns true or false.
$fileDelete = $client->deleteFile([
    'FileId' => $file->getId()

    // Can also identify the file via bucket and path:
    // 'BucketName' => 'my-special-bucket',
    // 'FileName' => 'path/to/file'
]);

// Retrieve an array of file objects from a bucket.
$fileList = $client->listFiles([
    'BucketId' => '4d2dbbe08e1e983c5e6f0d12'
]);

/*
 * Retrieve file versions from a bucket. Returns array. Optional parameters:
 *    StartFileName - The first file name to return.
 *    StartFileId - The first file ID to return. startFileName must also be
 *        provided if startFileId is specified.
 *    MaxFileCount - The maximum number of files to return.
 *    Prefix - Files returned will be limited to those with the given prefix.
 *        Defaults to the empty string, which matches all files.
 *    Delimiter - The delimiter character will be used to "break" file names
 *        into folders.
 * @see https://www.backblaze.com/b2/docs/b2_list_file_versions.html
 */
$fileVersions = $client->listFileVersions([
    'BucketId' => '4d2dbbe08e1e983c5e6f0d12',
]);
```

Tests
-----

[](#tests)

Tests are run with PHPUnit. After installing PHPUnit via Composer:

```
$ vendor/bin/phpunit
```

Change Log
----------

[](#change-log)

Release changes are noted on the [Releases](https://github.com/dmhendricks/b2-sdk-php/releases) page.

#### Branch: `master`

[](#branch-master)

- None

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~75 days

Recently: every ~197 days

Total

14

Last Release

2807d ago

Major Versions

v0.3.0 → v1.0.02016-02-18

v0.4.0 → v1.0.12016-02-24

PHP version history (3 changes)v0.1.0PHP &gt;=5.6.0

v1.1.0PHP &gt;=5.5.0

1.3.3PHP &gt;=5.6.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8184361?v=4)[Daniel M. Hendricks](/maintainers/dmhendricks)[@dmhendricks](https://github.com/dmhendricks)

---

Top Contributors

[![dmhendricks](https://avatars.githubusercontent.com/u/8184361?v=4)](https://github.com/dmhendricks "dmhendricks (12 commits)")[![coolcodemy](https://avatars.githubusercontent.com/u/14998386?v=4)](https://github.com/coolcodemy "coolcodemy (5 commits)")[![matslindh](https://avatars.githubusercontent.com/u/101525?v=4)](https://github.com/matslindh "matslindh (4 commits)")[![przemekperon](https://avatars.githubusercontent.com/u/169778?v=4)](https://github.com/przemekperon "przemekperon (2 commits)")[![miyurusankalpa](https://avatars.githubusercontent.com/u/1833185?v=4)](https://github.com/miyurusankalpa "miyurusankalpa (1 commits)")[![svenluijten](https://avatars.githubusercontent.com/u/11269635?v=4)](https://github.com/svenluijten "svenluijten (1 commits)")

---

Tags

backblaze-apibackblaze-b2filesystemcloudbackupstorageb2backblaze

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dmhendricks-b2-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/dmhendricks-b2-sdk-php/health.svg)](https://phpackages.com/packages/dmhendricks-b2-sdk-php)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[obregonco/backblaze-b2

An SDK for working with B2 cloud storage.

2734.0k](/packages/obregonco-backblaze-b2)[gliterd/backblaze-b2

PHP SDK for working with backblaze B2 cloud storage.

83274.0k8](/packages/gliterd-backblaze-b2)[cwhite92/b2-sdk-php

A SDK for working with B2 cloud storage.

74151.7k2](/packages/cwhite92-b2-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
