2017 © Pedro Peláez
 

library laravel-rackspace-cdn

Updated version of ThomasWelton's because that repo seems to be inactive

image

braunson/laravel-rackspace-cdn

Updated version of ThomasWelton's because that repo seems to be inactive

  • Monday, October 23, 2017
  • by BraunsonYager
  • Repository
  • 1 Watchers
  • 1 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

README for Laravel 4.x is here, (*1)

Installation

Run command in your terminal to include this package as a dependency:, (*2)

composer require braunson/laravel-rackspace-opencloud

Register the OpenCloud service provider and alias the OpenCloud, Str (removed in Laravel 5.0+) facades by adding it to the providers and aliases arrays in the config/app.php file., (*3)

For Laravel 5.5 and later don't need (auto discovery)., (*4)

For Laravel 5.2 - 5.4:, (*5)

'providers' => [
    Braunson\LaravelRackspaceCdn\LaravelRackspaceCdnServiceProvider::class
];
'aliases' => [
    'OpenCloud' => Braunson\LaravelRackspaceCdn\Facades\OpenCloud::class,
    'Str' => Illuminate\Support\Str::class,
]

For Laravel 5.1 and earlier:, (*6)

'providers' => [
    'Braunson\LaravelRackspaceCdn\LaravelRackspaceCdnServiceProvider'
]
'aliases' => [
    'OpenCloud' => 'Braunson\LaravelRackspaceCdn\Facades\OpenCloud',
    'Str' => 'Illuminate\Support\Str',
]

Configuration

Copy the config files into your project by running:, (*7)

php artisan vendor:publish --provider="Braunson\LaravelRackspaceCdn\LaravelRackspaceCdnServiceProvider"

Edit the config file to include your username, api key, region and url (internal or public)., (*8)

Usage

Artisan Commands

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

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

php artisan cdn:sync public/assets

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

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

You can configure your package.json to do this as NPM task:, (*12)

"scripts": {
    "cdn:sync": "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., (*13)

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., (*14)

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., (*15)

Upload to CDN

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 Request::file();
  • $name - (string) Optional file name to be used when saving the file to the CDN.

Example:, (*16)

Route::post('/upload', function()
{ 
    // '\Input' alias was removed from the default aliases in Laravel 5.2+
    if(Request::hasFile('image')){
        $file = OpenCloud::upload('my-container', Request::file('image'));
    }

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

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

Delete from CDN

OpenCloud::delete($container, $file)

The Versions

23/10 2017

dev-master

9999999-dev

Updated version of ThomasWelton's because that repo seems to be inactive

  Sources   Download

The Requires

 

by Avatar thomaswelton

23/10 2017

0.5.0

0.5.0.0

Updated version of ThomasWelton's because that repo seems to be inactive

  Sources   Download

The Requires

 

by Avatar thomaswelton

21/04 2015

0.4.1

0.4.1.0

Updated version of ThomasWelton's because that repo seems to be inactive

  Sources   Download

The Requires

 

by Avatar thomaswelton

24/01 2014

0.4.0

0.4.0.0

  Sources   Download

The Requires

 

by Avatar thomaswelton

14/11 2013

0.3.0

0.3.0.0

  Sources   Download

The Requires

 

by Avatar thomaswelton

03/11 2013

0.2.3

0.2.3.0

  Sources   Download

The Requires

 

by Avatar thomaswelton

01/11 2013

0.2.2

0.2.2.0

  Sources   Download

The Requires

 

by Avatar thomaswelton

30/10 2013
01/10 2013
26/08 2013

0.0.1

0.0.1.0

  Sources   Download

The Requires

 

by Avatar thomaswelton