naturalweb / nwlaravel-filestorage
FileStorage for the Laravel PHP Framework
dev-master
2014-10-30 18:32 UTC
Requires
- php: >=5.3.0
- laravel/framework: ~4.2
- naturalweb/filestorage: dev-master
- naturalweb/nwlaravel: dev-master
Requires (Dev)
- mockery/mockery: 0.7.2
- phpunit/phpunit: 4.0.*
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-11-19 02:30:57 UTC
README
Installation
In the require
key of composer.json
file add the following
"naturalweb/nwlaravel-filestorage": "~0.1"
Run the Composer update comand
$ composer update
In your config/app.php
add 'NwLaravel\FileStorage\FileStorageServiceProvider'
to the end of the $providers
array
'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', ... 'NwLaravel\FileStorage\FileStorageServiceProvider', ),
At the end of config/app.php
add 'FileStorage' => 'NwLaravel\FileStorage\FileStorageFacade'
to the $aliases
array
'aliases' => array( 'App' => 'Illuminate\Support\Facades\App', 'Artisan' => 'Illuminate\Support\Facades\Artisan', ... 'FileStorage' => 'NwLaravel\FileStorageFacade', ),
Configuration
Publish config using artisan CLI.
php artisan config:publish naturalweb/nwlaravel-filestorage
The configuration to app/config/packages/naturalweb/nwlaravel-filestorage/config/filestorage.php
. This file will look somewhat like:
<?php /* |-------------------------------------------------------------------------- | Configuration FileStorage |-------------------------------------------------------------------------- */ return array( 'default' => 'filesystem', 'path_tmp' => sys_get_temp_dir(), 'storages' => array( 'filesystem' => array( 'root' => public_path('/uploads'), 'host' => url('uploads'), ), 's3' => array( 'root' => '/bucket', 'access' => 'your-access', 'secret' => 'your-secret', ), 'dropbox' => array( 'root' => '/folder', 'token' => 'your-token', 'app' => 'your-app', ), ), );
Usage
$name = 'name-file.txt'; $source = '/source/path/file.txt'; $folder = '/folder/destino'; $override = true; $bool = FileStorage::save($name, $source, $folder, $override);