PHPackages                             jtbairdsr/spaces-api - 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. [API Development](/categories/api)
4. /
5. jtbairdsr/spaces-api

ActiveLibrary[API Development](/categories/api)

jtbairdsr/spaces-api
====================

composer package for SociallyDev's awesome Spaces-Api project

0101PHP

Since Jan 29Pushed 8y agoCompare

[ Source](https://github.com/jtbairdsr/Spaces-API)[ Packagist](https://packagist.org/packages/jtbairdsr/spaces-api)[ RSS](/packages/jtbairdsr-spaces-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Spaces-API
==========

[](#spaces-api)

An API wrapper for DigitalOcean's Spaces object storage designed for easy use.

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

[](#installation)

```
> composer require jtbairdsr/spaces-api @dev
```

### Connecting

[](#connecting)

```
require_once 'vendor/autoload.php';

$key = "EXAMPLE_KEY";
$secret = "EXAMPLE_SECRET";

$space_name = "my-space";
$region = "nyc3";

$space = new SpacesConnect($key, $secret, $space_name, $region);
```

All available options:

###### SpacesConnect(REQUIRED KEY, REQUIRED SECRET, OPTIONAL SPACE's NAME, OPTIONAL REGION, OPTIONAL HOST);

[](#spacesconnectrequired-key-required-secret-optional-spaces-name-optional-region-optional-host)

### Uploading/Downloading Files

[](#uploadingdownloading-files)

```
$path_to_file = "image.png";

$space->uploadFile($path_to_file, "public");

$download_file = "image.png";
$save_as = "folder/downloaded-image.png";

$space->downloadFile($download_file, $save_as);
```

All available options:

###### uploadFile(REQUIRED PATH TO FILE, OPTIONAL PRIVACY (public|private) OPTIONAL NAME TO SAVE FILE AS);

[](#uploadfilerequired-path-to-file-optional-privacy-publicprivate-optional-name-to-save-file-as)

###### downloadFile(REQUIRED FILE TO DOWNLOAD, REQUIRED LOCATION TO SAVE IN);

[](#downloadfilerequired-file-to-download-required-location-to-save-in)

### Changing Privacy Settings

[](#changing-privacy-settings)

```
$file = "image.png";

$space->makePublic($file);
$space->makePrivate($file);
```

All available options:

###### makePublic(REQUIRED PATH TO FILE);

[](#makepublicrequired-path-to-file)

###### makePrivate(REQUIRED PATH TO FILE);

[](#makeprivaterequired-path-to-file)

### Creating Temporary Links

[](#creating-temporary-links)

```
$file = "image.png";
$valid_for = "1 day";

$link = $space->CreateTemporaryURL($file, $valid_for);
```

All available options:

###### CreateTemporaryURL(REQUIRED FILE NAME, OPTIONAL TIME LINK IS VALID FOR);

[](#createtemporaryurlrequired-file-name-optional-time-link-is-valid-for)

### Other File APIs

[](#other-file-apis)

```
//List all files and folders
$files = $space->listObjects();

//Check if a file/folder by that name already exists. True/False.
$space->doesObjectExist($file_name);

//Pull information about a single object.
$file_info = $space->getObject($file_name);

//Delete a file/folder.
$space->deleteObject($file_name);

//Upload a complete directory instead of a single file.
$space->uploadDirectory($path_to_directory, $key_prefix);

//Pull Access Control List information.
$acl = $space-listObjectACL($file_name);

//Update Access Control List information.
$space->PutObjectACL($file_name, $acl_info_array);
```

### Creating Spaces

[](#creating-spaces)

```
$new_space = "my-new-space";

$space->createSpace($new_space);
```

All available options:

###### createSpace(REQUIRED SPACE NAME, OPTIONAL REGION FOR SPACE);

[](#createspacerequired-space-name-optional-region-for-space)

### Switching Spaces

[](#switching-spaces)

```
$new_space = "my-new-space";

$space->setSpace($new_space);
```

All available options:

###### setSpace(REQUIRED SPACE NAME, OPTIONAL REGION FOR SPACE, OPTIONAL HOST);

[](#setspacerequired-space-name-optional-region-for-space-optional-host)

### Other Spaces APIs

[](#other-spaces-apis)

```
//List all Spaces available in account.
$spaces = $space->listSpaces();

//Delete a Space.
$space->destroyThisSpace();

//Download whole Space to a folder.
$space->downloadSpaceToDirectory($directory_to_download_to);

//Get the name of the current Space.
$space_name = $space->getSpaceName();

//Pull the CORS policy of the Space.
$cors = $space->listCORS();

//Update the CORS policy of the Space.
$space->putCORS($new_policy);

//Pull the Access Control List information of the Space.
$acl = $space->listSpaceACL();

//Update the Access Control List information of the Space.
$space->PutSpaceACL($new_acl);
```

### Handling Errors

[](#handling-errors)

```
try {
   $space->createSpace("dev");
} catch (\Exception $e) {
  $error = $space->GetError($e);

   //Error management code.
   echo "";
   print_r($error);
   /*
   EG:
   Array (
    [message] => Bucket already exists
    [code] => BucketAlreadyExists
    [type] => client
    [http_code] => 409
   )
   */
}
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/97821ac080d6929407f0dcfa7239d068dd8d57e366a325c4b400ccf1c8baab5b?d=identicon)[jtbairdsr](/maintainers/jtbairdsr)

---

Top Contributors

[![SociallyDev](https://avatars.githubusercontent.com/u/29544121?v=4)](https://github.com/SociallyDev "SociallyDev (34 commits)")[![jtbairdsr](https://avatars.githubusercontent.com/u/6847062?v=4)](https://github.com/jtbairdsr "jtbairdsr (4 commits)")

### Embed Badge

![Health badge](/badges/jtbairdsr-spaces-api/health.svg)

```
[![Health](https://phpackages.com/badges/jtbairdsr-spaces-api/health.svg)](https://phpackages.com/packages/jtbairdsr-spaces-api)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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