appsco/filesystembundle

使用不同的文件系统

安装: 101

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 5

分支: 2

类型:项目

1.0.0-rc.3 2014-09-25 09:31 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:16:46 UTC


README

它用于在不同的文件系统中浏览、创建、读取和删除文件和文件夹。支持Rackspace OpenCloud和本地文件系统。

先决条件

此版本的bundle需要Symfony ~2.2和Rackspace OpenCloud v1.10.0

安装

步骤 1:使用composer下载appsco/filesystembundle

将 appsco/filesystembundle 添加到你的 composer.json 依赖中

{
    "require": {
        "appsco/filesystembundle": "dev-master"
    }
}

查看bundle 发布 中的最新稳定版本。

步骤 2:将bundle加载到kernel中

将 Add AppscoFilesystemBundle 添加到你的项目的kernel中

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Appsco\FilesystemBundle\AppscoFilesystemBundle(),
    );
}

现在你可以开始了。使用此配置,你可以使用本地文件系统。

进一步配置 - Rackspace OpenCloud

首先,你需要获取用于云文件的用户名和apiKey。获取数据后,你可以继续进行进一步配置。默认配置设置为LON区域。如果你使用的是相同的区域,配置的最小要求如下

appsco_filesystem:
    rackspace:
        client:
            username: %username%
            apikey: %apikey%

以下是Rackspace OpenCloud的完整配置(config.json)。

appsco_filesystem:
    rackspace:
        client:
            username: %username%
            apikey: %apikey%
            url: %url%
        objectstore:
            type: ~
            name: ~
            region: LON
            urlType: ~

使用bundle

要使用此bundle,调用服务 appsco_ket_filesystem.filesystem,然后检索你想要使用的卷以及用于操作文件系统的适配器。

  // tmp folder must be create so that file system can mount it for further use
  $localFs = $this->get('appsco_filesystem.filesystem')->getVolume('/tmp', 'local');

  // Fere volume represents the container that you would like to use
  $rackspaceFs = $this->get('appsco_filesystem.filesystem')->getVolume('container', 'rackspace');