Developed with love by KnpLabs Hire us for your project!
29

RackspaceCloudFilesBundle

by liuggio

[MOVED!!!!! see tvision/RackspaceCloudFilesBundle ]Symfony2 bundle to manage Rackspace Cloud Files, This Bundle borns as fork of the escapestudios/EscapeRackspaceCloudFilesBundle,...

Introduction

Rackspace Cloud Files bundle is a simple and easy way to use the namespaced version of php-cloudfiles with Symfony2 applications,

but it has also some facilities for handle the static file with the rackspace cloud files.

This Bundle borns as fork of the escapestudios/EscapeRackspaceCloudFilesBundle, now these two bundles are very different.

Build Status

see the blog post for more detail

http://www.welcometothebundle.com/symfony2-assets-on-rackspace-cloud-files/

Installation (old school)

see the blog post for more detail

deps:

[php-cloudfiles]
    git=git://github.com/rackspace/php-cloudfiles.git
    target=/rackspace/php-cloudfiles

[RackspaceCloudFilesBundle]
    git=https://github.com/liuggio/RackspaceCloudFilesBundle.git
    target=/bundles/Liuggio/RackspaceCloudFilesBundle

[RackspaceCloudFilesStreamWrapper]
    git=https://github.com/liuggio/RackspaceCloudFilesStreamWrapper.git
    target=liuggio-rscf-streamwrapper

app/autoload.php

$loader->registerNamespaces(array(
    //other namespaces
    'Liuggio\\RackspaceCloudFilesStreamWrapper' =>  __DIR__.'/../vendor/liuggio-rscf-streamwrapper/src',
    'Liuggio\\RackspaceCloudFilesBundle'        =>  __DIR__.'/../vendor/bundles',
  ));

require_once __DIR__.'/../vendor/rackspace/php-cloudfiles/cloudfiles.php';

app/AppKernel.php

public function registerBundles()
{
    return array(
        //other bundles
        new Liuggio\RackspaceCloudFilesBundle\LiuggioRackspaceCloudFilesBundle(),
    );
    ...

Installation Composer

  • 1 First, add the dependent bundles to the vendor/bundles directory. Add the following lines to the composer.json file
    "require": {
    # ..
    "liuggio/rackspace-cloud-files-bundle": ">=2.0",
    # ..
    }
  • 2 Then run composer install

  • 3 Then add in your app/AppKernel


 class AppKernel extends Kernel
 {
     public function registerBundles()
     {
         $bundles = array(
         // ...
            new Liuggio\RackspaceCloudFilesBundle\LiuggioRackspaceCloudFilesBundle(),
         // ...

Configuration

app/config/config.yml

#  Rackspace Cloud Files configuration

liuggio_rackspace_cloud_files:
    service_class: Liuggio\RackspaceCloudFilesStreamWrapper\StreamWrapper\RackspaceCloudFilesStreamWrapper
    stream_wrapper:
        register: true  # do you want to register stream wrapper?
#        protocol_name: rscf
#        class: Liuggio\StreamWrapper\RackspaceCloudFilesStreamWrapper
    auth:
        username: YOUR-USERNAME
        api_key: YOUR-API-KEY
        host: https://lon.auth.api.rackspacecloud.com # or usa
        container_name: YOUR-CONTAINER-NAME
        region: LON # or DFW or ORD

Service(s)

Get the Rackspace service to work with:

$auth = $this->get('liuggio_rackspace_cloud_files.service')

Usage example without assetic


$conn = $this->get('liuggio_rackspace_cloud_files.service');
$container = $conn->apiGetContainer('container-name');

or

$container = $this->get('liuggio_rackspace_cloud_files.service')->apiGetContainer('container-name');

echo "<pre>";
printf("Container %s has %d object(s) consuming %d bytes\n",
    $container->name, $container->count, $container->bytes);
echo "</pre>";

Usage example with assetic

see

http://www.welcometothebundle.com/symfony2-assets-on-rackspace-cloud-files/

Installing bundles assets (public directory) to cloudfiles with rscf:assets:install special console command

app/console rscf:assets:install rscf://my_container/my/path

This will copy assets just like the assets:install command would but directly to cloudfiles.
Note: For those wondering why this command could be needed, note that assetic mainly handles js/css assets, and when
not using the cssembed filter, you still need to install images to your cloudfiles container. This command prevent you
from having to do that by hand.

Installing application assets (public directory) to cloudfiles with assetic:install special console command

add this into the config.yml

assetic:
    debug: false
    use_controller: false
    write_to: rsfc://%rackspace_container_name%

Type to the console

app/console assetic:dump

Requirements

  • PHP > 5.3.0

  • rackspace/php-cloudfiles.git

  • liuggio/RackspaceCloudFilesStreamWrapper

  • Symfony2

Contribute

Please feel free to use the Git issue tracking to report back any problems or errors. You're encouraged to clone the repository and send pull requests if you'd like to contribute actively in developing the library.
than add your name to this file under the contributor section

Contributor

  • thanks for cystbear for the tips

  • the bundle is a reengeneering of the escapestudios/EscapeRackspaceCloudFilesBundle

  1. liuggio

  2. benjamindulau

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE
Copyright (c) Giulio De Donato

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
liuggio_rackspace_cloud_files:
container_prefix:
service_class: Liuggio\RackspaceCloudFilesBundle\Service\RSCFService
stream_wrapper:
register: false
protocol_name: rscf
class: \Liuggio\RackspaceCloudFilesStreamWrapper\StreamWrapper\RackspaceCloudFilesStreamWrapper
auth:
username: ~
api_key: ~
container_name: ~
host: https://lon.identity.api.rackspacecloud.com/v2.0
region: LON
  • Merge pull request #10 from cdwlighting/master
    By liuggio, 7 years ago
  • Added new parameter to the the Readme.md file to show how to add default region to the yaml config.
    By cdwlighting, 7 years ago
  • Added new parameter to the the Readme.md file to show how to add default region to the yaml config.
    By cdwlighting, 7 years ago
  • Added configuration for region parameter to configuration file, added an additional parameter to the constructor of the rackspace api, that takes a region, this is also defaulted to LON. Then updated the service.yml to pass the region parameter to the co
    By cdwlighting, 7 years ago
  • Merge pull request #8 from toretto460/master
    By liuggio, 7 years ago
  • Update README.md
    By toretto460, 7 years ago
  • Fixed Doc
    By toretto460, 7 years ago
  • Fixed Command and tests
    By toretto460, 7 years ago
  • merged with upstream
    By toretto460, 7 years ago
  • Cleaned code
    By toretto460, 7 years ago
  • Added Rackspace opencloud api
    By toretto460, 7 years ago
  • Merge pull request #7 from Gianpiero2012/master
    By liuggio, 7 years ago
  • modified command to upload from local directory with filter path, bundle, bundles
    By Gianpiero, 7 years ago
  • modificato command
    By Gianpiero, 7 years ago
  • Fixed dependency and test
    By toretto460, 7 years ago
  • Merge pull request #4 from benjamindulau/assets_install_readme
    By liuggio, 7 years ago
  • Fixed typo
    By benjamindulau, 7 years ago
  • Added a note about the new rscf:assets:install command in README
    By benjamindulau, 7 years ago
  • improved composer installation
    By liuggio, 7 years ago
  • added MIT license
    By liuggio, 7 years ago
  • fixed unit test, added composer section to the readme
    By liuggio, 7 years ago
  • Merge pull request #3 from benjamindulau/assets_install_command
    By liuggio, 7 years ago
  • Added a rscf:assets:install command to install assets directly to rackspace cloudfiles
    By benjamindulau, 7 years ago
  • Renamed package
    By toretto460, 8 years ago
  • Removed wrong packagist dependence
    By toretto460, 8 years ago
  • stop composer problem
    By liuggio, 8 years ago
  • still composer dependency
    By liuggio, 8 years ago
  • composer fixed
    By liuggio, 8 years ago
  • composer updated
    By liuggio, 8 years ago
  • fixed composer
    By liuggio, 8 years ago