5

What is the best symfony file system abstract layer ? i need to set up a file system at my symfony project, something similar to dropbox. i dont know where the files/medias are going to be stored or how, so thats why i need that abstract layer, to set it up and dont bother about updateing the files location.

what i need to do:

-adding folders/files
-moveing folder/files to another lcoation
-delating folder/files
-download folder/files
-upload folder/files
-editing folder/files
-editing name of folder/files

do you know any good bundles for it ? any good solutioins for symfony 2 ? and please tell my why can this solution be good for my ?

vardius
  • 6,326
  • 8
  • 52
  • 97

2 Answers2

29

The currently available options seem to be:

1) Gaufrette

In order to transfer something you need to put it in memory first. This is a problem when you have to deal with huge files. Gaufrette has filesystem abstraction layer, but makes it impossible to move objects between filesystems. Some essential features are also missing, for example - removing a directory.

Feels more like a key-value storage emulator with different adapters.

2) Filicious

On paper seem promising, but in fact its not. The documentation is all wrong. It mentions namespaces that does not exist and classes that are not to be found. Most of the stuff around Filicious currently don't seem to be implemented. The only working adapter as of now is the Local one. You can track the progress on their website.

3) Flysystem

Looks better than the above mentioned. Has stream support. They also have this MountManager, which you can use for transferring files between different filesystems.

In summary, my choice would be Flysystem. You should better check it yourself if it will fit your requirements.

Nikola Petkanski
  • 4,724
  • 1
  • 33
  • 41
  • would you please cite the point related to in memory first handling of files in Gaufrette? This is a concern for me in a project I am working on, but I can't find anything about it anywhere. – Mosab Ibrahim Nov 27 '16 at 14:37
  • It's in the codebase. You can see that they use file_get_contents() on the Local adapter, which would get the file binary content and would put it to a variable. Should this file be like 5GB or so, you would have 5GB memory consumption by the variable. Same goes for other adapters. The FTP one, for example, uses stream_get_contents(). While fetching the full file in memory would work for small files, it is a blocker for huge ones. Streams should be used instead. – Nikola Petkanski Nov 28 '16 at 12:54
  • 2
    This page and comment should both be much higher in the Google rankings than they are. Personally, I've used both Gaufrette and Flysystem in a few projects and, for all the info you find around the net, Gaufrette seems the right choice but, in reality, it's a pain in the ass. Flysystem with it's mountmanager makes file handling the way it should be – Simon Dec 03 '17 at 02:35
0

https://github.com/KnpLabs/KnpGaufretteBundle

Certainly the most in-depth implementation, it includes dropbox.

Flosculus
  • 6,880
  • 3
  • 18
  • 42
  • but how do i upload some media files like movies or images? doesnt it work only for txt files? `$content = 'Hello I am the new content'; $filesystem->write('myFile', $content);` – vardius Jan 16 '14 at 10:42
  • I haven't used it personally. I just know it abstracts filesystem management. I imagine it doesn't care what filetypes are uploaded. – Flosculus Jan 16 '14 at 10:54
  • i found nice tutorial how to upload an image do amazon with gaufrette: http://braincrafted.com/symfony2-gaufrette-s3/ i think it can be helpfull – vardius Jan 16 '14 at 10:57
  • but does it allow me to get the folder content and display it for example filename type table ? or something? – vardius Jan 16 '14 at 11:00
  • i asked `what is the best file system abstact layer?` and also said that i need something similar to `dropbox` so it also includes the browsing options, it's not another question but the deeper meaning of it. – vardius Jan 16 '14 at 11:11
  • Maybe, but this will result in extended discussion which is frowned upon here. Research Gaufrette, you may find it more rewarding to discover its capabilities on your own. Then if you still have issues using it, at least you will have a better understanding. – Flosculus Jan 16 '14 at 11:14
  • If you look deeper into Gaufrette, it is more a key/value storage engine than a filesystem abstraction layer. For example, their AdapterInterface doesn't have a method to list contents of a directory, which is essential when working with filesystems. Flysystem has dropbox support, as well as all essential methods you would expect from a true filesystem. – Karolis Mar 06 '16 at 15:42
  • @Karolis I only suggested it because it what the OP wanted. If there were any serious performance requirements, I'd write my own layer. – Flosculus Mar 17 '16 at 09:22