PHPackages                             softlayer/objectstorage - 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. softlayer/objectstorage

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

softlayer/objectstorage
=======================

PHP bindings for SoftLayer Object Storage

2910.2k—0%17[15 issues](https://github.com/softlayer/softlayer-object-storage-php/issues)2PHP

Since Aug 12Pushed 10y ago12 watchersCompare

[ Source](https://github.com/softlayer/softlayer-object-storage-php)[ Packagist](https://packagist.org/packages/softlayer/objectstorage)[ RSS](/packages/softlayer-objectstorage/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (2)

SoftLayer Object Storage PHP Client
===================================

[](#softlayer-object-storage-php-client)

PHP bindings for SoftLayer Object Storage

Install
=======

[](#install)

Unzip the files and make sure to include lib/ObjectStorage/Util.php once somewhere in your script

Requirements
============

[](#requirements)

```
* Mandatory
    * PHP version > 5.2
	* PHP OpenSSL extension (if your PHP is compiled by your self, make sure compile it with: --with-openssl configure)
* Optional
    * Zend Framework (for HTTP Client)
    * CURL

```

Documents
=========

[](#documents)

Documents are generated by PHPDocumentor. See docs directory for details.

Tests
=====

[](#tests)

The test cases are run using phpunit version PHPUnit 3.5.13 To run a test, provide your object storage credentials in test/BaseTest.php file.

Examples
========

[](#examples)

Configuring Object Storage
--------------------------

[](#configuring-object-storage)

```
// If you want to cache ObjectStorage authentication token:
$tokenStore = ObjectStorage_TokenStore::factory('file', array('ttl' => 3600, 'path' => '/tmp/objectStorage'));
ObjectStorage::setTokenStore($tokenStore);

// If no adapter option is provided, CURL will be used.
$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
 $host = 'https://dal05.objectstorage.softlayer.net'; // the SoftLayer Object Storage API host
 $username = 'SLOS778231112-1:3241234'; // user name and password is display at https://manage.softlayer.com/ObjectStorage/index
 $password = 'ksd83ksd8ksdfhx823ks8cksew8slsdi82ls8xlsd8l';

$objectStorage = new ObjectStorage($host, $username, $password, $options);
```

Basic CRUD
----------

[](#basic-crud)

```
$containerList = $objectStorage->with()->get();

$containerName = $containerList->getPath();

$shallowContainer = $objectStorage->with('example_container');

$newContainer = $shallowContainer->create();

$updatedContainer = $newContainer->setMeta('Description', 'Adding a meta data')->update();

$reloadedContainer = $newContainer->get();

$result = $newContainer->delete();

// Creating an object is similar to that of container CRUD
// This library will try to guess the content-type for an object if you don't provide it.
// An object without an extension (pseudo sub-directory) will have application/directory content-type.
$newObject = $objectStorage->with('example_container/object.txt')
                            ->setBody('test object')
                            ->setMeta('description', 'first test file')
                            ->create();

// You can copy a local file to Object Storage.
// This will stream local file data to Object Storage. Keep in mind, most PHP configurations will support a file size up to 2 GB.
$newObject = $objectStorage->with('example_container/large_file.zip')
                            ->setLocalFile('/path/to/local/file')
                            ->setMeta('description', 'large local file upload')
                            ->setHeader('Content-type', 'application/zip')
                            ->create();

// You can copy a remote file in Object Storage.
// This will trigger a remote copy on the cluster (which is significantly faster than streaming down and up the file/headers).
$newObject = $objectStorage->with('example_container/large_file_duplicate.zip')
                            ->copyFrom('/example_container/large_file.zip')
                            ->create();

// If you wanted, you can do this all one line.
// Most functions return itself so you can chain method calls except delete method which returns a boolean value.
$result = $objectStorage->with('example_container')
                        ->create()
                        ->setMeta('Description', 'Adding a meta data')
                        ->update()
                        ->get()
                        ->delete();

// When you create a new container or an object, ObjectStorage_Abstract will return itself, not the newly created container or object.
// If you wish to reload the data from ObjectStorage cluster, use ObjectStorage_Abstract::get or ObjectStorage_Abstract::reload methods.
// It will fetch the container info from ObjectStorage and reload $newContainer object with it.
$newContainer = $objectStorage->with('example_container')->create()->reload();
```

CDN operations
--------------

[](#cdn-operations)

```
// To create a CDN enabled container
$objectStorage->with('cdn_container')->enableCdn()->create();

// To update an existing container to a CDN enabled container
$objectStorage->with('another_container')->enableCdn()->setTtl(3600)->update();

// You want to see CDN URLs?
$cdnUrls = $container->getCdnUrls();

// CDN purge cache. (In case you modified an object and need to refresh CDN cache.)
$objectStorage05->with('cdn_container/object')->purgeCache();

// CDN load cache
$objectStorage05->with('cdn_container/object')->loadCache();

// If you want to compress *text* files served via CDN.
$results = $objectStorage05->with('')->setContext('cdn')
                    ->setHeader('X-CDN-COMPRESSION', 'true') // Set to "false" to turn off compression
                    ->setHeader('X-CDN-COMPRESSION-MIME', 'text/plain,text/html,text/css,application/x-javascript,text/javascript')
                    ->update();

// If you want to add a custom CDN CNAME. (
// You can add a CNAME to a container level as well. To do so, pass an appropriate container name to with() method
// Keep in mind you can have only one custom CNAME per container
// To find your CNAME endpoint, use "dig" command on your existing CDN host. For example,
// $ dig 1234.http.dal05.cdn.softlayer.net
$results = $objectStorage05->with('')->setContext('cdn')
                    ->setHeader('X-CDN-CNAME-Action', 'add') // Use "delete" if you wish to delete a CNAME
                    ->setHeader('X-Cdn-CNAME', 'cdn.mysite.com')
                    ->update();
```

Traversing containers or objects
--------------------------------

[](#traversing-containers-or-objects)

```
$container = $objectStorage->with('another_container')->get();
if (count($container->objects) > 0) {
    foreach ($container->objects as $shallowObject) {
        $object = $shallowObject->get(); // Defaults to 100 results, pass a parameter to override eg. ->get(500)

        echo $object->getUrl();
        echo $object->getBody();
    }
}
```

Pseudo-hierarchical directories
-------------------------------

[](#pseudo-hierarchical-directories)

```
/**
 * If you have a container and an object as below and you want to retrieve pseudo sub-directories,
 * use the "prefix" and "delimiter" query parameters.
 *
 * - some_container/sub_dir/2012/object.file
 */

$container = $objectStorage01->with('some_container')
                ->setParam('delimiter', '/')
                ->setParam('prefix', '')
                ->setMime('json')
                ->get();

// Response body (json) will include {"subdir":"sub_dir/"}
// You can traverse to the final object by setting the "subdir" value as the new "prefix" value.
// To retrieve the next level pseudo directory:
...
            ->setParam('prefix', 'sub_dir/');
...
```

Pagination
----------

[](#pagination)

```
/**
 * You can traverse the directories through pages of data using markers.
 *
 */

$container = $objectStorage01->with('some_container')
                ->setParam('marker', '/some_container/last_item_name_on_previous_page.jpg')
                ->get(25);

// You can progress backwards through the directories using "end_marker" too

$container = $objectStorage01->with('some_container')
                ->setParam('end_marker', '/some_container/first_item_name_on_previous_page.jpg')
                ->get(25);
```

Copy an object to another Object Storage
----------------------------------------

[](#copy-an-object-to-another-object-storage)

```
$objectStorage01 = new ObjectStorage($host01, $username01, $password01);
$objectStorage02 = new ObjectStorage($host02, $username02, $password02);

$object = $objectStorage01->with('container/object')->get();
$objectStorage02->create($object);
```

Search
------

[](#search)

```
$objectOrContainer = $objectStorage05->with('')
                                    ->setContext('search')
                                    ->setFilter('type', 'container')
                                    ->setFilter('q', $searchKeyword)
                                    ->setMime('json')
                                    ->get();
```

Notes
-----

[](#notes)

ObjectStorage\_Abstract has many properties but these three are the major componets.

```
* $objectStorage: holds reference to a ObjectStorage object (optional)
* $request: HTTP request object is consisted of headers and body
* $response: HTTP response object is consisted of headers and body

```

You can access to HTTP request or response object using ObjectStorage\_Abstract::getRequest or ObjectStorage\_Abstract::getResponse. You can also use convenience getter and setters. These can help you avoid doing like this:

```
$container->getResponse()->setMeta('description', 'example meta');
$container->getRequest()->getBody();
```

But you can do this instead:

```
$container->setMeta('description', 'example meta');
$container->getBody();
```

The idea is that you *set* data to HTTP request and *get* data from HTTP response.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6cd82fe6c374f9eb5731935465deba0607261831707f8ea2f93e814808433956?d=identicon)[Softlayer](/maintainers/Softlayer)

---

Top Contributors

[![its-clee](https://avatars.githubusercontent.com/u/1434994?v=4)](https://github.com/its-clee "its-clee (22 commits)")[![briancline](https://avatars.githubusercontent.com/u/32032?v=4)](https://github.com/briancline "briancline (9 commits)")[![follower46](https://avatars.githubusercontent.com/u/1760421?v=4)](https://github.com/follower46 "follower46 (5 commits)")[![adamh114](https://avatars.githubusercontent.com/u/661106?v=4)](https://github.com/adamh114 "adamh114 (3 commits)")[![martinj](https://avatars.githubusercontent.com/u/194438?v=4)](https://github.com/martinj "martinj (2 commits)")[![lorenzoaiello](https://avatars.githubusercontent.com/u/671054?v=4)](https://github.com/lorenzoaiello "lorenzoaiello (2 commits)")[![DVSoftware](https://avatars.githubusercontent.com/u/429515?v=4)](https://github.com/DVSoftware "DVSoftware (1 commits)")[![CrackerJackMack](https://avatars.githubusercontent.com/u/136956?v=4)](https://github.com/CrackerJackMack "CrackerJackMack (1 commits)")[![etaoins](https://avatars.githubusercontent.com/u/687534?v=4)](https://github.com/etaoins "etaoins (1 commits)")

### Embed Badge

![Health badge](/badges/softlayer-objectstorage/health.svg)

```
[![Health](https://phpackages.com/badges/softlayer-objectstorage/health.svg)](https://phpackages.com/packages/softlayer-objectstorage)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15161.6M2.6k](/packages/illuminate-filesystem)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)[madnest/madzipper

Easier zip file handling for Laravel applications.

1382.3M6](/packages/madnest-madzipper)

PHPackages © 2026

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