dmyers/laravel-storage

A simple storage filesystem package for Laravel 4.

Installs: 2 700

Dependents: 2

Stars: 100

Watchers: 10

Forks: 11

Open Issues: 4

Language: PHP

v1.0.9 2014-09-05 23:32 UTC

README

Storage is a filesystem abstraction layer for Laravel 4 applications.

Installation via Composer

Add this to you composer.json file, in the require object:

"dmyers/laravel-storage": "1.*"

After that, run composer install to install Storage.

Add the service provider to app/config/app.php, within the providers array.

'providers' => array(
    // ...
    'Dmyers\Storage\StorageServiceProvider',
)

Add a class alias to app/config/app.php, within the aliases array.

'aliases' => array(
    // ...
    'Storage' => 'Dmyers\Storage\Storage',
)

Finally, ensure the files directory defined in the config file is created and writable by the web server (defaults to public/files).

$ mkdir public/files
$ chmod -R 777 public/files

Configuration

Publish the default config file to your application so you can make modifications.

$ php artisan config:publish dmyers/laravel-storage

Usage

Check if a file exists in storage:

Storage::exists('user/avatar.jpg');

Get a file's contents from storage:

Storage::get('user/avatar.jpg');

Put a file into storage:

Storage::put('user/avatar.jpg', $contents);

Upload a file into storage:

Storage::upload(Input::file('avatar'), 'user/avatar.jpg');

Download a file from storage:

Storage::download('user/avatar.jpg', 'tmp/images/user-1/avatar.jpg');

Delete a file from storage:

Storage::delete('user/avatar.jpg');

Move a file in storage:

Storage::move('user/avatar.jpg', 'user/1/avatar.jpg');

Copy a file in storage:

Storage::copy('user/avatar.jpg', 'user/avatar.bak.jpg');

Get a file's type from storage:

Storage::type('user/avatar.jpg');

Get a file's mime type from storage:

Storage::mime('user/avatar.jpg');

Get a file's size from storage:

Storage::size('user/avatar.jpg');

Get a file's last modification date from storage:

Storage::lastModified('user/avatar.jpg');

Check if a path is a directory in storage:

Storage::isDirectory('user/avatar.jpg');

List all files in storage:

Storage::files('images');

Get the full URL to a file in storage:

Storage::url('user/avatar.jpg');

Render a file from storage to the browser:

Storage::render('user/avatar.jpg');