Giter Site home page Giter Site logo

php-opencloud-zf2's Introduction

php-opencloud-zf2

A simple but powerful ZF2 module that allows your web app to communicate easily with Rackspace/OpenStack APIs. You can manage your cloud account configurations, use Swift helper functions in your view files, monitor your cloud servers, sync directories with a CDN, update DNS records... In short, you get the full benefit of an SDK without all the overhead.

Installation

Step 1: Install Composer (if you haven't already)

curl -sS https://getcomposer.org/installer | php

Step 2: Install the module

php composer.phar require jamiehannaford/php-opencloud-zf2:dev-master

This will automatically update your composer.json configuration file and force Composer to install the module. Alternatively, you can manually insert the requirement like so:

{
    "require": {
        "jamiehannaford/php-opencloud-zf2": "~1.0"
    }
}

And then run:

php composer.phar install

Step 3: ZF2 Configuration

You need to update your application.config.php file, and add in the module:

return array(
    'modules' => array(
        // other modules...
        'OpenCloud'
    )
);

You then need to make sure you have an opencloud.local.php configuration file in your config/autoload directory - since this is what holds all your API configuration values. To make life easier, you can copy the dist version shipped with this project:

cp ./vendor/jamiehannaford/php-opencloud-zf2/config/opencloud.local.php.dist ./config/autoload/opencloud.local.php

If using Rackspace, you must fill in the username and apiKey config options.

If using OpenStack, you must fill in the username, password config options, along with either tenantId or tenantName.

Usage

You can retrieve a Rackspace client object using the Service Manager:

public function indexAction()
{
    // get Rackspace client
    $rackspace = $this->getServiceLocator()->get('OpenCloud');

    // this also works
    $rackspace = $this->getServiceLocator()->get('OpenCloud\Rackspace');

    // get OpenStack client
    $openstack = $this->getServiceLocator()->get('OpenCloud\OpenStack');
}

Once this client object is available, you have full access to the php-opencloud SDK.

View helpers

Please see the CloudFilesHelper wiki for more information about how you can streamline the process of accessing CDN resources in your HTML views.

php-opencloud-zf2's People

Contributors

alexeykosov avatar jamiehannaford avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

alexeykosov

php-opencloud-zf2's Issues

Can't be used on production

The module config is incompatible with "config_cache_enabled" option which is often used on production servers. (http://framework.zend.com/manual/current/en/tutorials/config.advanced.html)

The reason is that closures are used in module.config.php and when it's cached and merged with another config files, the result looks like:

  'OpenCloud\\OpenStack' => 
  Closure::__set_state(array(
  )),
  'OpenCloud\\Rackspace' => 
  Closure::__set_state(array(
  )),

which causes a fatal error.

You should get rid of closures in module.config.php file (move them to Module.php or to separate factory classes).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.