Need help with laravel-storage?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

dmyers
100 Stars 5 Forks MIT License 39 Commits 1 Opened issues

Description

A simple filesystem abstraction package for Laravel 4.

Services available

!
?

Need anything else?

Contributors list

# 29,356
PHP
Laravel
HTML
html-em...
35 commits
# 5,930
Laravel
Racket
CSS
Svelte
2 commits

Storage Package for Laravel 4

Storage is a filesystem abstraction layer for Laravel 4 applications. If you are using Laravel 5 it comes with a similar package included which can be found in the docs.

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');

Upload a remote file into storage:

Storage::remoteUpload('http://laravel.com/favicon.ico', 'user/avatar.jpg');

Download a file from storage:

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

Download a remote file locally:

Storage::remoteDownload('http://laravel.com/favicon.ico', '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');

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.