2017 © Pedro Peláez
 

library laravel-rackspace-opencloud

image

thomaswelton/laravel-rackspace-opencloud

  • Monday, May 16, 2016
  • by thomaswelton
  • Repository
  • 3 Watchers
  • 29 Stars
  • 14,919 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 14 Forks
  • 11 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Latest Stable Version Total Downloads Bitdeli Badge, (*1)

Installation

Update your composer.json file to include this package as a dependency, (*2)

"thomaswelton/laravel-rackspace-opencloud": "dev-master"

Register the OpenCloud service provider by adding it to the providers array in your app/config/app.php file., (*3)

'providers' => array(
    Thomaswelton\LaravelRackspaceOpencloud\LaravelRackspaceOpencloudServiceProvider
)

Alias the OpenCloud facade by adding it to the aliases array in the app/config/app.php file., (*4)

'aliases' => array(
    'OpenCloud' => 'Thomaswelton\LaravelRackspaceOpencloud\Facades\OpenCloud'
)

Configuration

Copy the config file into your project by running, (*5)

php artisan config:publish thomaswelton/laravel-rackspace-opencloud

Edit the config file to include your username, api key and region., (*6)

Usage

Artisan Commands

Upload files via the command line., (*7)

Synchronize a whole directory. Copies all files to /public/assets, (*8)

php artisan cdn:sync public/assets

Copies all files to /assets trimming 'public' from the path, (*9)

php artisan cdn:sync public/assets --trim=public

The sync command will save a file adjacent to the synchronized directory. It contains the http and https urls for your container. Along with a md5 hash of the directory. In this way when a file changes inside a directory and is reuploaded you get a new cache busted URL., (*10)

If you are using the URL helper then it will return a CDN url for a file, if it finds a *.cdn.json file adjacent to one of it's parent directories., (*11)

URL::asset('assets/image.jpg');

You should be able to run php artisan cdn:sync public/assets --trim=public before or during a deployment and once complete all files being called by URL::asset() will return a CDN resource, (*12)

Upload to CDN

Using this method will make the container public, even if previously set as private. This is a known issue yet to be addressed., (*13)

OpenCloud::upload($container, $file, $name = null)
  • $container - (string) Name of the container to upload into
  • $file - (string / UploadedFile) Path to file, or instance of 'Symfony\Component\HttpFoundation\File\UploadedFile' as returned by Input::file()
  • $name - (string) Optional file name to be used when saving the file to the CDN.

Example:, (*14)

Route::post('/upload', function()
{
    if(Input::hasFile('image')){
        $file = OpenCloud::upload('my-container', Input::file('image'));
    }

    $cdnUrl = $file->PublicURL();
    // Do something with $cdnUrl

    return Redirect::to('/upload');
});

Delete from CDN

OpenCloud::delete($container, $file)

The Versions

16/05 2016

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Avatar thomaswelton

16/05 2016

0.4.1

0.4.1.0

  Sources   Download

The Requires

 

by Avatar thomaswelton

24/01 2014

0.4.0

0.4.0.0

  Sources   Download

The Requires

 

by Avatar thomaswelton

26/08 2013