PHPackages                             black-bits/bestcdn-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. [HTTP &amp; Networking](/categories/http)
4. /
5. black-bits/bestcdn-sdk-php

AbandonedLibrary[HTTP &amp; Networking](/categories/http)

black-bits/bestcdn-sdk-php
==========================

PHP SDK for the bestcdn service

0.1.9(7y ago)0226MITPHPPHP &gt;=7.0.0

Since Oct 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/black-bits/bestcdn-sdk-php)[ Packagist](https://packagist.org/packages/black-bits/bestcdn-sdk-php)[ Docs](https://github.com/black-bits/bestcdn-sdk-php)[ RSS](/packages/black-bits-bestcdn-sdk-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (17)Used By (0)

BestCDN SDK PHP
===============

[](#bestcdn-sdk-php)

PHP SDK to work with BestCDN.

It contains optional Laravel support.

**Currently unstable aka. work in progress, use at your own discretion.**

How to install
--------------

[](#how-to-install)

To add this package to your app

```
composer require black-bits/bestcdn-sdk-php

```

Using Laravel you need to publish the config

```
php artisan vendor:publish --provider="BlackBits\BestCdn\BestCdnServiceProvider"

```

How to use
----------

[](#how-to-use)

### Laravel

[](#laravel)

Using Laravel you can use the SDK in multiple ways.

#### Using the Facade

[](#using-the-facade)

```
$key     = "myPath/myFileName.ext";      // desired path on cdn
$file    = __DIR__ . "/file.ext";        // local absolute path
$respose = BestCdn::putFile($key, $file);
```

#### Using Dependency Injection

[](#using-dependency-injection)

For example inside a Controller

```
class FileController extends Controller
{
    public function putFile(Request $request, BestCdn $cdn)
    {
        // ...
        $key     = "myPath/myFileName.ext"; // desired path on cdn
        $file    = __DIR__ . "/file.ext";   // local absolute path
        $respose = $cdn->putFile($key, $file);
        // ...
    }
}
```

### In other frameworks or standalone PHP

[](#in-other-frameworks-or-standalone-php)

If you do not use the Laravel Framework you need to instantiate the base class with a default config first

```
$config = [

    'connections' => [
        'default' => [
            "credentials" => [
                "key"    => "YourBestCdnProjectKey",    // required
                "secret" => "YourBestCdnProjectSecret", // required
            ],
            "defaultRequestOptions" => [
                "base_uri" => "https://management.bestcdn.io/", // required - e.g. sandbox(testing) or production endpoint
                "verify"   => true,                             // optional - can be set to false for local testing (does not enforce SSL verification)
            ],
        ],
    ],

    "defaultConnection" => "default", // optional, if you configure multiple connections (multiple projects/testing/production)
];

$cdn     = new BestCdn($config);
$key     = "myPath/myFileName.ext"; // desired path on cdn
$file    = __DIR__ . "/file.ext";   // local absolute path
$respose = $cdn->putFile($key, $file);
```

### Making a request

[](#making-a-request)

#### putFile()

[](#putfile)

When making a request to store a file on the CDN you need to provide the desired **key** and a **file**.

The **key** represents the sub-path within your project namespace (the public path on the CDN will end in /{project-name}-{customer-name}/{key}).

The **file** should be an absolute path to a file.

```
$key     = "myPath/myFileName.md"; // desired path on cdn
$file    = __DIR__ . "/README.md"; // local absolute path
$respose = $cdn->putFile($key, $file);
```

#### putFileByUri()

[](#putfilebyuri)

When making a request to store a file on the CDN via URI you need to provide the desired **key** and a **uri**. The CDN will download the file from the given URI.

The **key** represents the sub-path within your project namespace (the public path on the CDN will end in /{project-name}-{customer-name}/{key}).

The **uri** should be a valid, publicly accessible uri of a file.

```
$key     = "myPath/myFileName.jpeg";                                           // desired path on cdn
$uri     = "https://static.pexels.com/photos/460797/pexels-photo-460797.jpeg"; // public uri
$respose = $cdn->putFileByUri($key, $uri);
```

### Handling Results

[](#handling-results)

After a successful request you get the response data like this:

```
var_dump($response->data());
```

Results in:

```
array(1) {
  ["cdn_link"]=>
  string(139) "https://staging.master.bestcdn.io/project_1-customer_01/example/image_profile/250x250_10.jpg"
}

```

To access file properties (like the cdn\_link) you can use convenience methods like this:

```
$response['cdn_link'];
$response->get('cdn_link');
```

### Handling Errors

[](#handling-errors)

For error handling we provide a standardised exception as well as default error handling.

You handle common errors like this:

```
$cdn = new BestCdn($config);

$key  = "myPath/myFileName.md";
$file = __DIR__ . "/README.md";

$result = $cdn->putFile($key, $file);
if ( $result->hasError() ) {
    print $result->statusCode();
    print $result->message();
    // ... abort mission!
}

// ... normal code
```

Common errors will include routine, non critical errors like trying to get information on or deleting a non existing file.

Exceptions will be thrown if the error needs to be handled (authentication error, etc.).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~22 days

Recently: every ~79 days

Total

16

Last Release

2795d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c5817559bd224c59f893745c3bbfa308db2786b67e16c4c44cc4472826e9d571?d=identicon)[aprzywara](/maintainers/aprzywara)

![](https://www.gravatar.com/avatar/12f99b0d20f4c0281e21cd28d12a44d2789c673a5bacade150d0e1150bdd9464?d=identicon)[oheck](/maintainers/oheck)

---

Top Contributors

[![aprzywara](https://avatars.githubusercontent.com/u/10901792?v=4)](https://github.com/aprzywara "aprzywara (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/black-bits-bestcdn-sdk-php/health.svg)

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

###  Alternatives

[mateusjunges/laravel-kafka

A kafka driver for laravel

7163.1M17](/packages/mateusjunges-laravel-kafka)[illuminate/http

The Illuminate Http package.

11936.0M5.1k](/packages/illuminate-http)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[spatie/laravel-export

Create a static site bundle from a Laravel app

646127.9k5](/packages/spatie-laravel-export)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)

PHPackages © 2026

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