liuggio / rackspace-cloud-files-bundle
为 #Symfony2 Bundles 提供Rackspace云文件支持
Requires
- php: >=5.3.2
- liuggio/rackspace-cloud-files-streamwrapper: dev-master
- rackspace/php-cloudfiles: dev-master
- symfony/symfony: 2.*
This package is auto-updated.
Last update: 2023-10-19 19:13:16 UTC
README
Rackspace Cloud Files bundle 是一个简单易用的方式,在 Symfony2 应用程序中使用命名空间版本的 php-cloudfiles,
但它也为处理 Rackspace 云文件中的静态文件提供了一些功能。
这个 Bundle 是由 escapestudios/EscapeRackspaceCloudFilesBundle 分支出来的,现在这两个 Bundle 有很大的不同。
更多信息请查看博客文章
http://www.welcometothebundle.com/symfony2-assets-on-rackspace-cloud-files/
安装(老式方法)
更多信息请查看博客文章
依赖
[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(),
);
...
安装 Composer
- 1 首先,将依赖的包添加到 vendor/bundles 目录。将以下行添加到 composer.json 文件中
"require": {
# ..
"liuggio/rackspace-cloud-files-bundle": ">=2.0",
# ..
}
-
2 然后,运行
composer install
-
3 然后,在
app/AppKernel
中添加
class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Liuggio\RackspaceCloudFilesBundle\LiuggioRackspaceCloudFilesBundle(), // ...
配置
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
服务(们)
获取与 Rackspace 服务一起工作的服务
$auth = $this->get('liuggio_rackspace_cloud_files.service')
没有 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>";
使用 assetic 的使用示例
查看
http://www.welcometothebundle.com/symfony2-assets-on-rackspace-cloud-files/
使用特殊控制台命令 rscf:assets:install
将包资源(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-cloudfiles.git
-
liuggio/RackspaceCloudFilesStreamWrapper
-
Symfony2
贡献
请随意使用 Git 问题跟踪来报告任何问题或错误。如果您想积极参与库的开发,鼓励您克隆存储库并发送 pull 请求。然后请将您的名字添加到该文件的下 contributor 部分
贡献者
-
感谢 cystbear 的提示
-
这个包是对 escapestudios/EscapeRackspaceCloudFilesBundle 的重构
-
liuggio
-
benjamindulau
许可证
此包受 MIT 许可证保护。在包中查看完整的许可证
Resources/meta/LICENSE