, (*1)
Introduction
Rackspace Cloud Files bundle is a simple and easy way to use the RackspaceCloudFilesStreamWrapper library with Symfony2 applications,, (*2)
but it has also some facilities for handle the static file with the rackspace cloud files., (*3)
This Bundle borns as fork of the escapestudios/EscapeRackspaceCloudFilesBundle, now these two bundles are very different., (*4)
see the blog post for more detail, (*5)
http://www.welcometothebundle.com/symfony2-assets-on-rackspace-cloud-files/, (*6)
Installation (old school)
see the blog post for more detail, (*7)
deps:, (*8)
``` ini
[php-opencloud]
git=git://github.com/rackspace/php-opencloud.git
target=/rackspace/php-opencloud, (*9)
[RackspaceCloudFilesBundle]
git=https://github.com/tvision/RackspaceCloudFilesBundle.git
target=/bundles/Tvision/RackspaceCloudFilesBundle, (*10)
[RackspaceCloudFilesStreamWrapper]
git=https://github.com/tvision/RackspaceCloudFilesStreamWrapper.git
target=tvision-rackspace-cloud-files-streamwrapper, (*11)
app/autoload.php
``` php
$loader->registerNamespaces(array(
//other namespaces
'Tvision\\RackspaceCloudFilesStreamWrapper' => __DIR__.'/../vendor/tvision-rackspace-cloud-files-streamwrapper/src',
'Tvision\\RackspaceCloudFilesBundle' => __DIR__.'/../vendor/bundles',
));
app/AppKernel.php, (*12)
``` php
public function registerBundles()
{
return array(
//other bundles
new Tvision\RackspaceCloudFilesBundle\TvisionRackspaceCloudFilesBundle(),
);
..., (*13)
Installation Composer
-------------------------------
* 1 First, add the dependent bundle to the vendor/bundles directory. Add the following lines to the composer.json file
``` javascript
"require": {
// ..
"tvision/rackspace-cloud-files-bundle": "~3.0",
// ..
}
-
2 Then run composer install
, (*14)
-
3 Then add in your app/AppKernel
, (*15)
``` php, (*16)
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Tvision\RackspaceCloudFilesBundle\TvisionRackspaceCloudFilesBundle(),
// ..., (*17)
## Configuration
app/config/config.yml
``` yaml
# 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
Service(s)
Get the Rackspace service to work with:, (*18)
``` php
$auth = $this->get('tvision_rackspace_cloud_files.service'), (*19)
## Usage example without assetic
``` php
$conn = $this->get('tvision_rackspace_cloud_files.service');
$container = $conn->apiGetContainer('container-name');
or, (*20)
``` php
$container = $this->get('tvision_rackspace_cloud_files.service')->apiGetContainer('container-name');, (*21)
echo ", (*22)
";
printf("Container %s has %d object(s) consuming %d bytes\n",
$container->name, $container->count, $container->bytes);
echo "
";, (*23)
## 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
``` bash
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., (*24)
Installing application assets (public directory) to cloudfiles with assetic:install
special console command
add this into the config.yml, (*25)
``` yaml
assetic:
debug: false
use_controller: false
write_to: rsfc://%rackspace_container_name%, (*26)
Type to the console
``` bash
app/console assetic:dump
Requirements
-
PHP > 5.3.0, (*27)
-
rackspace/php-opencloud.git, (*28)
-
tvision/RackspaceCloudFilesStreamWrapper, (*29)
-
Symfony2, (*30)
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, (*31)
Contributor
-
thanks for cystbear for the tips, (*32)
-
the bundle is a reengeneering of the escapestudios/EscapeRackspaceCloudFilesBundle, (*33)
-
liuggio, (*34)
-
benjamindulau, (*35)
-
toretto460, (*36)
License
This bundle is under the MIT license. See the complete license in the bundle:, (*37)
Resources/meta/LICENSE