自然网络 / nwlaravel-filestorage
用于Laravel PHP框架的文件存储
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-09-24 01:51:19 UTC
README
安装
在composer.json
文件的require
键中添加以下内容:
"naturalweb/nwlaravel-filestorage": "~0.1"
运行Composer更新命令
$ composer update
在您的config/app.php
文件中,将'NwLaravel\FileStorage\FileStorageServiceProvider'
添加到$providers
数组的末尾
'providers' => array( 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 'Illuminate\Auth\AuthServiceProvider', ... 'NwLaravel\FileStorage\FileStorageServiceProvider', ),
在config/app.php
文件的末尾添加'FileStorage' => 'NwLaravel\FileStorage\FileStorageFacade'
到$aliases
数组
'aliases' => array( 'App' => 'Illuminate\Support\Facades\App', 'Artisan' => 'Illuminate\Support\Facades\Artisan', ... 'FileStorage' => 'NwLaravel\FileStorageFacade', ),
配置
使用Artisan CLI发布配置。
php artisan config:publish naturalweb/nwlaravel-filestorage
配置文件位于app/config/packages/naturalweb/nwlaravel-filestorage/config/filestorage.php
。此文件可能看起来如下:
<?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', ), ), );
用法
$name = 'name-file.txt'; $source = '/source/path/file.txt'; $folder = '/folder/destino'; $override = true; $bool = FileStorage::save($name, $source, $folder, $override);