Abstract layer for working with file system

Notice: This thread is very old.
arron
Member | 464
+
0
-

I would be cool to have some abstract layer for file system. Then it would be possible to easily implement the AWS S3 storage for example.

It there any plan for this? Or did anyone work on something like that?

Thank you a lot.

na1k
Member | 288
+
0
-

Is this what you are looking for?

Or you can implement custom file protocol (mystorage://) and use it with the Finder

arron
Member | 464
+
0
-

I am really sorry, I was out of my mind when I was asking this question:-) Nette has its abstract layer, for example cache is using it.

But I found, that sessions is using native php functions. So what to do, when I want to save sessions somewhere else? There is some ISessionStorage, but it seems to not be used at all.

na1k wrote:

Is this what you are looking for?

Or you can implement custom file protocol (mystorage://) and use it with the Finder

That looks interesting, thank you.

Last edited by arron (2011-08-29 20:24)

Jan Tvrdík
Nette guru | 2595
+
0
-

arron wrote:

So what to do, when I want to save sessions somewhere else? There is some ISessionStorage, but it seems to not be used at all.

Just configure sessions to use your session storage via Nette\Http\Session::setStorage().

arron
Member | 464
+
0
-

This was the point, where looking into source-code was unsuccessfull, because I wasn't looking deep enaugh. Thank you!

vkrishn
Member | 9
+
0
-

Is there implementation for simple file operations, like:

  1. Check if file/folder present.
  2. Create dir with desired permissions.
  3. Unlink
  4. Process fileperms() or stats(), symlinks.
  5. Guess file mime-type.
  6. Simple read/write operations.

Can this be part of util/finder?
Storages\FileStorage could use this common methods.

HosipLan
Moderator | 4668
+
0
-

Why there would be such a tool? PHP can do this on it's own. Nette always was, and will be lightweight.

vkrishn
Member | 9
+
0
-

Some of the classes do have these methods, to some extend, implemented internally.
Moving them to a common class perhaps Files.php under Nette\Utils or Nette\Caching\Storages can be done.

Overall the above methods can be implemented in less than 10kb file size. Not calculating the removal of some codes from some files in Storages and Config.

Building a product based application often requires an installation phase and module update routines. Having them inbuilt in a framework would be great.

David Grudl
Nette Core | 8218
+
0
-

For simple file operations there is native class SplFileObject. (API is terrible, but better than nothing).

vkrishn
Member | 9
+
0
-

The closest would be,

  1. http://pear.php.net/package/File/ (20%) – more if required, part of which is in Storages/FileStorage
  2. http://pear.php.net/…e/File_Find/ (60%) – part of which I guess is already in Utils/Finder
  3. http://pear.php.net/…e/File_Util/ (80%)
  4. A simple file type guessing based on extension.

Reason:
To build/deploy a product based on nette framework would require such routines.
Having them build in framework with nette style error handling.

Though implementing the above would be nice, I am in favour of a lightweight framework. :-)

Last edited by vkrishn (2012-03-22 05:52)