2017 © Pedro Peláez
 

library laravel-file-manager

File manager API (no UI) for Laravel

image

rdx/laravel-file-manager

File manager API (no UI) for Laravel

  • Tuesday, April 4, 2017
  • by rudiedirkx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 200 % Grown

The README.md

Laravel file manager

Scrutinizer Code Quality, (*1)

Keeps track of files and their usage. Works with an SQL backend by default., (*2)

Install

  1. Publish the config: php artisan vendor:publish
  2. Optionally alter the config: config/filemanager.php
  3. Install the schema (SQL provider, but you can make your own) php artisan migrate ^ This makes files and files_usage tables.
  4. Add the service provider: rdx\filemanager\FileManagerServiceProvider::class
  5. Inject the service: public function store(FileManager $files)

Save uploads

ManagedFile records will be the primary source of files, not the file system., (*3)

$uploaded = $request['picture']; // Illuminate\Http\UploadedFile

$managed = $files->saveFile($uploaded); // in root dir
$managed = $files->saveFile($uploaded, 'some/sub/dir'); // in sub dir

File usage

File usage is useful to automatically delete orphaned files, or make sure used files aren't deleted., (*4)

Usage is kept by creating a FileUsageContract. There are 2 provided, but your app can make others., (*5)

To truly customize file usage, change the migration to add usage columns, AND create custom usage objects to reflect those columns., (*6)

// Generic FileUsage
$managed->addUsage(new FileUsage('type', 'more', 'specific', 'keys'));
// Save this file's usage for [type, more:specific:keys]

// Model bound ModelFileUsage
$managed->addUsage(new ModelFileUsage($user, 'picture'));
// Save this file's usage for [User, 14:picture]

Deleting files

@todo Can't delete used files @todo Auto delete unused files, (*7)

To do

  • Deleting files
  • Use Laravel's file system helpers
  • Some kind of access control?

The Versions

04/04 2017

dev-master

9999999-dev

File manager API (no UI) for Laravel

  Sources   Download

MIT

The Requires

 

by Rudie Dirkx