tvision/rackspace-cloud-files-bundle

为 #Symfony2 Bundles 提供Rackspace 云文件支持

安装次数: 7,408

依赖项: 0

建议者: 0

安全: 0

星标: 5

关注者: 1

分支: 11

开放问题: 5

类型:symfony-bundle

v3.0.0 2013-11-13 17:09 UTC

This package is not auto-updated.

Last update: 2024-09-14 14:53:02 UTC


README

Build Status Latest Stable Version

简介

Rackspace Cloud Files bundle 是一个简单易用的库,允许在 Symfony2 应用程序中使用 RackspaceCloudFilesStreamWrapper 库,

同时提供了一些处理 Rackspace 云文件静态文件的设施。

这个 Bundle 最初是 escapestudios/EscapeRackspaceCloudFilesBundle 的分支,现在这两个 Bundle 差异很大。

请参阅博客文章了解更多细节

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

安装(老式方法)

请参阅博客文章了解更多细节

依赖

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

[RackspaceCloudFilesBundle]
    git=https://github.com/tvision/RackspaceCloudFilesBundle.git
    target=/bundles/Tvision/RackspaceCloudFilesBundle

[RackspaceCloudFilesStreamWrapper]
    git=https://github.com/tvision/RackspaceCloudFilesStreamWrapper.git
    target=tvision-rackspace-cloud-files-streamwrapper

app/autoload.php

$loader->registerNamespaces(array(
    //other namespaces
    'Tvision\\RackspaceCloudFilesStreamWrapper' =>  __DIR__.'/../vendor/tvision-rackspace-cloud-files-streamwrapper/src',
    'Tvision\\RackspaceCloudFilesBundle'        =>  __DIR__.'/../vendor/bundles',
  ));

app/AppKernel.php

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

安装 Composer

  • 1 首先,将依赖的 Bundle 添加到 vendor/bundles 目录。在 composer.json 文件中添加以下行:
    "require": {
    // ..
    "tvision/rackspace-cloud-files-bundle": "~3.0",
    // ..
    }
  • 2 然后,运行 composer install

  • 3 然后,在您的 app/AppKernel 中添加

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

配置

app/config/config.yml

#  Rackspace Cloud Files configuration

tvision_rackspace_cloud_files:
    stream_wrapper:
        register: true  # do you want to register stream wrapper?
        protocol_name: rscf
    auth:
        username: YOUR-USERNAME
        api_key: YOUR-API-KEY
        host: https://lon.identity.api.rackspacecloud.com/v2.0 # or https://identity.api.rackspacecloud.com/v2.0 (usa)
        container_name: YOUR-CONTAINER-NAME
        region: LON 

服务

获取 Rackspace 服务以进行工作

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

无 assetic 的使用示例

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

$container = $this->get('tvision_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>";

带有 assetic 的使用示例

请参阅

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

使用 rscf:assets:install 特殊控制台命令将 Bundle 资产(public 目录)安装到云文件中

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

这将像 assets:install 命令一样复制资产,但直接到云文件。**注意**:对于那些想知道为什么需要这个命令的人来说,请注意,Assetic 主要处理 js/css 资产,而在不使用 cssembed 过滤器的情况下,您仍然需要将图像安装到您的云文件容器中。此命令可以防止您手动执行此操作。

使用 assetic:install 特殊控制台命令将应用程序资产(public 目录)安装到云文件中

将此添加到 config.yml 中

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

在控制台输入

app/console assetic:dump

要求

  • PHP > 5.3.0

  • rackspace/php-opencloud.git

  • tvision/RackspaceCloudFilesStreamWrapper

  • Symfony2

贡献

请随时使用 Git 问题跟踪来报告任何问题或错误。如果您想积极地为库的开发做出贡献,请克隆存储库并发送拉取请求。然后在贡献者部分添加您的名字。

贡献者

  • 感谢 cystbear 的提示

  • 此 Bundle 是 escapestudios/EscapeRackspaceCloudFilesBundle 的重工程

  1. liuggio

  2. benjamindulau

  3. toretto460

许可证

此 Bundle 采用 MIT 许可证。请参阅 Bundle 中的完整许可证。

Resources/meta/LICENSE