{"id":23138220,"url":"https://github.com/softlayer/softlayer-object-storage-php","last_synced_at":"2025-08-28T06:04:19.916Z","repository":{"id":2468605,"uuid":"3441041","full_name":"softlayer/softlayer-object-storage-php","owner":"softlayer","description":"SoftLayer Object Storage PHP Client","archived":false,"fork":false,"pushed_at":"2015-08-12T19:45:06.000Z","size":416,"stargazers_count":29,"open_issues_count":15,"forks_count":17,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-05-19T12:09:26.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softlayer.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-02-14T15:32:29.000Z","updated_at":"2025-02-02T12:08:01.000Z","dependencies_parsed_at":"2022-09-12T11:44:34.847Z","dependency_job_id":null,"html_url":"https://github.com/softlayer/softlayer-object-storage-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/softlayer/softlayer-object-storage-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsoftlayer-object-storage-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsoftlayer-object-storage-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsoftlayer-object-storage-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsoftlayer-object-storage-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softlayer","download_url":"https://codeload.github.com/softlayer/softlayer-object-storage-php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsoftlayer-object-storage-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261170425,"owners_count":23119513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T13:10:10.434Z","updated_at":"2025-07-03T06:05:08.049Z","avatar_url":"https://github.com/softlayer.png","language":"PHP","readme":"SoftLayer Object Storage PHP Client\n====================================\nPHP bindings for SoftLayer Object Storage\n\n\n# Install\nUnzip the files and make sure to include lib/ObjectStorage/Util.php once somewhere in your script\n\n# Requirements\n    * Mandatory\n        * PHP version \u003e 5.2\n\t\t* PHP OpenSSL extension (if your PHP is compiled by your self, make sure compile it with: --with-openssl configure)\n    * Optional\n        * Zend Framework (for HTTP Client)\n        * CURL\n\n# Documents\nDocuments are generated by PHPDocumentor. See docs directory for details.\n\n# Tests\nThe test cases are run using phpunit version PHPUnit 3.5.13\nTo run a test, provide your object storage credentials in test/BaseTest.php file.\n\n# Examples\n\n## Configuring Object Storage\n\n```php\n\n// If you want to cache ObjectStorage authentication token:\n$tokenStore = ObjectStorage_TokenStore::factory('file', array('ttl' =\u003e 3600, 'path' =\u003e '/tmp/objectStorage'));\nObjectStorage::setTokenStore($tokenStore);\n\n// If no adapter option is provided, CURL will be used.\n$options = array('adapter' =\u003e ObjectStorage_Http_Client::SOCKET, 'timeout' =\u003e 10);\n $host = 'https://dal05.objectstorage.softlayer.net'; // the SoftLayer Object Storage API host\n $username = 'SLOS778231112-1:3241234'; // user name and password is display at https://manage.softlayer.com/ObjectStorage/index\n $password = 'ksd83ksd8ksdfhx823ks8cksew8slsdi82ls8xlsd8l';\n\n$objectStorage = new ObjectStorage($host, $username, $password, $options);\n```\n\n## Basic CRUD\n\n```php\n$containerList = $objectStorage-\u003ewith()-\u003eget();\n\n$containerName = $containerList-\u003egetPath();\n\n$shallowContainer = $objectStorage-\u003ewith('example_container');\n\n$newContainer = $shallowContainer-\u003ecreate();\n\n$updatedContainer = $newContainer-\u003esetMeta('Description', 'Adding a meta data')-\u003eupdate();\n\n$reloadedContainer = $newContainer-\u003eget();\n\n$result = $newContainer-\u003edelete();\n\n// Creating an object is similar to that of container CRUD\n// This library will try to guess the content-type for an object if you don't provide it.\n// An object without an extension (pseudo sub-directory) will have application/directory content-type.\n$newObject = $objectStorage-\u003ewith('example_container/object.txt')\n                            -\u003esetBody('test object')\n                            -\u003esetMeta('description', 'first test file')\n                            -\u003ecreate();\n\n// You can copy a local file to Object Storage.\n// This will stream local file data to Object Storage. Keep in mind, most PHP configurations will support a file size up to 2 GB.\n$newObject = $objectStorage-\u003ewith('example_container/large_file.zip')\n                            -\u003esetLocalFile('/path/to/local/file')\n                            -\u003esetMeta('description', 'large local file upload')\n                            -\u003esetHeader('Content-type', 'application/zip')\n                            -\u003ecreate();\n\n// You can copy a remote file in Object Storage.\n// This will trigger a remote copy on the cluster (which is significantly faster than streaming down and up the file/headers).\n$newObject = $objectStorage-\u003ewith('example_container/large_file_duplicate.zip')\n                            -\u003ecopyFrom('/example_container/large_file.zip')\n                            -\u003ecreate();\n\n// If you wanted, you can do this all one line.\n// Most functions return itself so you can chain method calls except delete method which returns a boolean value.\n$result = $objectStorage-\u003ewith('example_container')\n                        -\u003ecreate()\n                        -\u003esetMeta('Description', 'Adding a meta data')\n                        -\u003eupdate()\n                        -\u003eget()\n                        -\u003edelete();\n\n// When you create a new container or an object, ObjectStorage_Abstract will return itself, not the newly created container or object.\n// If you wish to reload the data from ObjectStorage cluster, use ObjectStorage_Abstract::get or ObjectStorage_Abstract::reload methods.\n// It will fetch the container info from ObjectStorage and reload $newContainer object with it.\n$newContainer = $objectStorage-\u003ewith('example_container')-\u003ecreate()-\u003ereload();\n```\n\n## CDN operations\n```php\n// To create a CDN enabled container\n$objectStorage-\u003ewith('cdn_container')-\u003eenableCdn()-\u003ecreate();\n\n// To update an existing container to a CDN enabled container\n$objectStorage-\u003ewith('another_container')-\u003eenableCdn()-\u003esetTtl(3600)-\u003eupdate();\n\n// You want to see CDN URLs?\n$cdnUrls = $container-\u003egetCdnUrls();\n\n// CDN purge cache. (In case you modified an object and need to refresh CDN cache.)\n$objectStorage05-\u003ewith('cdn_container/object')-\u003epurgeCache();\n\n// CDN load cache\n$objectStorage05-\u003ewith('cdn_container/object')-\u003eloadCache();\n\n// If you want to compress *text* files served via CDN.\n$results = $objectStorage05-\u003ewith('')-\u003esetContext('cdn')\n                    -\u003esetHeader('X-CDN-COMPRESSION', 'true') // Set to \"false\" to turn off compression\n                    -\u003esetHeader('X-CDN-COMPRESSION-MIME', 'text/plain,text/html,text/css,application/x-javascript,text/javascript')\n                    -\u003eupdate();\n\n// If you want to add a custom CDN CNAME. (\n// You can add a CNAME to a container level as well. To do so, pass an appropriate container name to with() method\n// Keep in mind you can have only one custom CNAME per container\n// To find your CNAME endpoint, use \"dig\" command on your existing CDN host. For example,\n// $ dig 1234.http.dal05.cdn.softlayer.net\n$results = $objectStorage05-\u003ewith('')-\u003esetContext('cdn')\n                    -\u003esetHeader('X-CDN-CNAME-Action', 'add') // Use \"delete\" if you wish to delete a CNAME\n                    -\u003esetHeader('X-Cdn-CNAME', 'cdn.mysite.com')\n                    -\u003eupdate();\n\n```\n\n## Traversing containers or objects\n```php\n$container = $objectStorage-\u003ewith('another_container')-\u003eget();\nif (count($container-\u003eobjects) \u003e 0) {\n    foreach ($container-\u003eobjects as $shallowObject) {\n        $object = $shallowObject-\u003eget(); // Defaults to 100 results, pass a parameter to override eg. -\u003eget(500)\n\n        echo $object-\u003egetUrl();\n        echo $object-\u003egetBody();\n    }\n}\n```\n\n## Pseudo-hierarchical directories\n```php\n/**\n * If you have a container and an object as below and you want to retrieve pseudo sub-directories,\n * use the \"prefix\" and \"delimiter\" query parameters.\n *\n * - some_container/sub_dir/2012/object.file\n */\n\n$container = $objectStorage01-\u003ewith('some_container')\n                -\u003esetParam('delimiter', '/')\n                -\u003esetParam('prefix', '')\n                -\u003esetMime('json')\n                -\u003eget();\n\n// Response body (json) will include {\"subdir\":\"sub_dir/\"}\n// You can traverse to the final object by setting the \"subdir\" value as the new \"prefix\" value.\n// To retrieve the next level pseudo directory:\n...\n            -\u003esetParam('prefix', 'sub_dir/');\n...\n```\n\n## Pagination\n```php\n/**\n * You can traverse the directories through pages of data using markers.\n *\n */\n\n$container = $objectStorage01-\u003ewith('some_container')\n                -\u003esetParam('marker', '/some_container/last_item_name_on_previous_page.jpg')\n                -\u003eget(25);\n\n// You can progress backwards through the directories using \"end_marker\" too\n\n$container = $objectStorage01-\u003ewith('some_container')\n                -\u003esetParam('end_marker', '/some_container/first_item_name_on_previous_page.jpg')\n                -\u003eget(25);\n```\n\n## Copy an object to another Object Storage\n\n```php\n$objectStorage01 = new ObjectStorage($host01, $username01, $password01);\n$objectStorage02 = new ObjectStorage($host02, $username02, $password02);\n\n$object = $objectStorage01-\u003ewith('container/object')-\u003eget();\n$objectStorage02-\u003ecreate($object);\n```\n\n## Search\n```php\n$objectOrContainer = $objectStorage05-\u003ewith('')\n                                    -\u003esetContext('search')\n                                    -\u003esetFilter('type', 'container')\n                                    -\u003esetFilter('q', $searchKeyword)\n                                    -\u003esetMime('json')\n                                    -\u003eget();\n```\n\n\n## Notes\nObjectStorage_Abstract has many properties but these three are the major componets.\n\n    * $objectStorage: holds reference to a ObjectStorage object (optional)\n    * $request: HTTP request object is consisted of headers and body\n    * $response: HTTP response object is consisted of headers and body\n\nYou can access to HTTP request or response object using ObjectStorage_Abstract::getRequest or ObjectStorage_Abstract::getResponse.\nYou can also use convenience getter and setters. These can help you avoid doing like this:\n\n```php\n$container-\u003egetResponse()-\u003esetMeta('description', 'example meta');\n$container-\u003egetRequest()-\u003egetBody();\n```\n\nBut you can do this instead:\n\n```php\n$container-\u003esetMeta('description', 'example meta');\n$container-\u003egetBody();\n```\n\nThe idea is that you *set* data to HTTP request and *get* data from HTTP response.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftlayer%2Fsoftlayer-object-storage-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftlayer%2Fsoftlayer-object-storage-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftlayer%2Fsoftlayer-object-storage-php/lists"}