PHPackages                             anton-am/do-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. [File &amp; Storage](/categories/file-storage)
4. /
5. anton-am/do-spaces-api

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

anton-am/do-spaces-api
======================

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

1.0.9(4mo ago)0736MITPHPPHP &gt;=7.2.0

Since Aug 2Pushed 4mo agoCompare

[ Source](https://github.com/Anton-Am/do-spaces-api)[ Packagist](https://packagist.org/packages/anton-am/do-spaces-api)[ RSS](/packages/anton-am-do-spaces-api/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (10)Dependencies (9)Versions (11)Used By (0)

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

[](#spaces-api)

[![FOSSA Status](https://camo.githubusercontent.com/f697099fd8b2f3e0ae0c79d391b0666d577c49f627a2cf26274b039ec443259d/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246536f6369616c6c794465762532465370616365732d4150492e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bgithub.com%2FSociallyDev%2FSpaces-API?ref=badge_shield)

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

### Installation

[](#installation)

- **Using Composer**:

```
composer require sociallydev/spaces-api:dev-master
```

### Connecting

[](#connecting)

```
//Either:
require_once("spaces.php");
//OR COMPOSER:
require_once("vendor/autoload.php"); //Install first by executing: composer require SociallyDev/Spaces-API in your project's directory.

$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)

```
// Don't start any path with a forward slash, or it will give "SignatureDoesNotMatch" exception
$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)

### Deleting Files/Folders

[](#deleting-filesfolders)

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

$space->DeleteObject($file_name);
```

All available options:

###### DeleteObject(REQUIRED FILE OR FOLDER TO DELETE, OPTIONAL RECURSIVE (false|true));

[](#deleteobjectrequired-file-or-folder-to-delete-optional-recursive-falsetrue)

### 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);

//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 (\SpacesAPIException $e) {
  $error = $e->GetError();

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

License
-------

[](#license)

[![FOSSA Status](https://camo.githubusercontent.com/c197405eddc28ba32aae130a4bd59fc6b1342a2dad7599afd0b99f120b4f3891/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f6769742532426769746875622e636f6d253246536f6369616c6c794465762532465370616365732d4150492e7376673f747970653d6c61726765)](https://app.fossa.io/projects/git%2Bgithub.com%2FSociallyDev%2FSpaces-API?ref=badge_large)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance75

Regular maintenance activity

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 69.6% 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 ~259 days

Recently: every ~419 days

Total

10

Last Release

138d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af13af0d5187f733f6b7cb67a3dc40b5df3c7e1783d4aa5b7023d8ff4f2471c0?d=identicon)[Anton-Am](/maintainers/Anton-Am)

---

Top Contributors

[![SociallyDev](https://avatars.githubusercontent.com/u/29544121?v=4)](https://github.com/SociallyDev "SociallyDev (55 commits)")[![Anton-Am](https://avatars.githubusercontent.com/u/2063230?v=4)](https://github.com/Anton-Am "Anton-Am (16 commits)")[![Abdelhady](https://avatars.githubusercontent.com/u/2075626?v=4)](https://github.com/Abdelhady "Abdelhady (2 commits)")[![AndreyNazarchuk](https://avatars.githubusercontent.com/u/7192775?v=4)](https://github.com/AndreyNazarchuk "AndreyNazarchuk (2 commits)")[![bilaltas](https://avatars.githubusercontent.com/u/12401765?v=4)](https://github.com/bilaltas "bilaltas (1 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")[![richellyitalo](https://avatars.githubusercontent.com/u/1899604?v=4)](https://github.com/richellyitalo "richellyitalo (1 commits)")[![alessandroaussems](https://avatars.githubusercontent.com/u/22371019?v=4)](https://github.com/alessandroaussems "alessandroaussems (1 commits)")

###  Code Quality

TestsCodeception

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/anton-am-do-spaces-api/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

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

6.3k511.3M2.2k](/packages/aws-aws-sdk-php)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[google/cloud

Google Cloud Client Library

1.2k16.2M54](/packages/google-cloud)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M788](/packages/league-flysystem-aws-s3-v3)[aws/aws-sdk-php-laravel

A simple Laravel 9/10/11/12/13 service provider for including the AWS SDK for PHP.

1.7k35.6M74](/packages/aws-aws-sdk-php-laravel)[stechstudio/laravel-zipstream

A fast and simple streaming zip file downloader for Laravel.

4633.7M3](/packages/stechstudio-laravel-zipstream)

PHPackages © 2026

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