Skip to content

boxlight/php-opencloud-service-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

php-opencloud-service-provider

A basic Silex service provider for rackspace/php-opencloud.

Knowledge of the rackspace/php-opencloud library is required.

Installation

{
    "repositories": [
        { "type": "vcs", "url": "git@github.com:boxlight/php-opencloud-service-provider.git" }
    ],
    "require": {
        "boxlight/php-opencloud-service-provider": "dev-master"
    }
}

Initialisation

<?php
    // bootstrap.php
    $app->register(new Boxlight\Silex\Provider\OpenCloud\OpenCloudServiceProvider(), array(

        // change to 'OpenStack' for non-Rackspace
        // see https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/authentication.md#authenticating-against-openstack-clouds
        'opencloud.variant' => 'Rackspace',
        'opencloud.endpoint' => OpenCloud\Rackspace::UK_IDENTITY_ENDPOINT,
        'opencloud.secret' => array(
            'username' => 'foo',
            'apiKey' => 'bar'
        ),

        // import/export is sometimes required
        // "some deployments will limit the frequency with which you can authenticate."
        // see https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/authentication.md#credential-caching
        'opencloud.importCredentials' => $app->protect(function() use ($app) {
            return load_credentials_from_cache();
        }),

        // if this isn't callable, the credentials will become stored here
        // you can access $app['opencloud.exportCredentials'] once they have
        'opencloud.exportCredentials' => $app->protect(function($credentials) use ($app) {
            store_credentials_in_cache($credentials);
        })

    ));

Usage

<?php
    // helloworld.php
    $store = $app['opencloud']->objectStoreService('cloudFiles', 'LON', 'publicURL');
    $container = $store->getContainer('my container');

    do_something_useful($container->getObjectCount());

About

A Silex Service Provider for Rackspace Opencloud

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages