Re: AW: [PEAR-DEV] Re: [Proposal] Stream_Var
| From: | Stefan Neufeind | Date: | Fri, 15 Aug 2003 22:15:40 +0000 |
| Subject: | Re: AW: [PEAR-DEV] Re: [Proposal] Stream_Var | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-19845@lists.php.net to get a copy of this message | ||
From the technical point I like it very much. Not yet knew that this
was a new addition in 4.3.2 - but you never stop learning.
From the practical view: As Stephan said it might be useful if you
want to use any functions that rely on files and that you now can
simply point "to memory". Hey, if you e.g. receive a blob with an ogg-
vorbis-stream from a DB now you can still use File_Ogg to retrieve
the meta-data :-)
Or even better: If you have graphics that come from an arbitrary
source you can use it to read in the files via GD.
If I think about it further ... What if you use Archive_Tar or
something and read files directly from a tar into a variable and use
them from memory with any functions that normally rely on a file?
Stephan: Do you think an interface for integrating e.g. Archive_Tar
or similar would be possible so you can transparently read from an
archive? But this is just a side-thought :-)
The idea is great and the implementation looks promising. Generally
I'm +1 on this topic.
Stefan
On 15 Aug 2003 at 23:44, Stephan Schmidt wrote:
> Hi,
>
> At first, I did this to experiment with the new stream wrappers.
> But I think it's usefull when developing an application that relies on
> dirs and files that do not exists. You just build the structure in
> memory and work with this structures like they were the directories
> and files that the app will later use. So I think it's something that
> will be used quite often when you are debugging your application, as
> it's easier to fill an array than creating a lot of directories if you
> do only need them for some miniutes to test your application.
>
> The question "Why not use the direct method" could be asked for other
> stream wrappers as well, there's no need to use Stream_SHM, as you
> could use the shm_* functions, but using stream wrappers adds a nice
> level of data abstraction.
>
> Stephan
>
> > -----Ursprüngliche Nachricht-----
> > Von: Greg Beaver [mailto:greg@chiaraquartet.net]
> > Gesendet: Freitag, 15. August 2003 23:38
> > An: schst@php-tools.net
> > Cc: pear-dev@lists.php.net; gerd@php-tools.de; argh@php-tools.de
> > Betreff: [PEAR-DEV] Re: [Proposal] Stream_Var
> >
> >
> > Hi Stephan,
> >
> > I'm having a bit of difficulty imagining a reason I would use this
> > instead of just accessing an array, can you provide a practical
> > example, maybe the one that inspired you to write this, if there was
> > anything?
> >
> > Greg
> >
> > Stephan Schmidt wrote:
> > > Hi PEAR-Devs,
> > >
> > > I'd like to propose a new package called Stream_Var. This package
> > > allows stream based access to variables using the stream
> > wrappers that
> > > have been introduced in PHP4.3.2
> > >
> > > That means you can do things like:
> > >
> > > $fp = fopen('var://GLOBALS/anyGlobalVar', 'r');
> > >
> > > and then use fread, fwrite, fseek, etc. on this filepointer to
> > > read from and modify the variable. It supports GLOBALS, GET,
> > POST, etc. If
> > > 'anyGlobalVar' is an array, it behaves like a directory, that
> > > means you could do the following:
> > >
> > > $fp = fopen('var://GLOBALS/anyGlobalVar/anyKey', 'r');
> > >
> > > of course with an unlimited depth :-)
> > >
> > > As arrays are directories, also the following is possible:
> > >
> > > $dir = opendir('var://GET');
> > > while($entry = readdir($dir)) {
> > > echo "$entry<br />";
> > > }
> > >
> > > I still need to implement some minor things like different
> > file modes
> > > (r,r+,w,w+,a,...) and options so it's possible to trigger
> > errors, that
> > > give more detail, but the basic functionality is included.
> > > @Greg: Yes, I know that I still have to include some inline
> > > documentation, on which problem it does solve :-) I'll do
> > that before
> > > the first version is released.
> > >
> > > You can take a look at the sourcecode at:
> > > http://www.php-tools.de/PEAR/Stream_Var/Var.phps
> > >
> > > Download it, with examples from:
> > >
> > > http://www.php-tools.de/PEAR/Stream_Var/Stream_var.zip
> > >
> > > You can also take a look at the sourcecode of the examples at:
> > >
> > > http://www.php-tools.de/PEAR/Stream_Var/examples/example.phps
> > >
> > > http://www.php-tools.de/PEAR/Stream_Var/examples/example2.phps
> > >
> > > The will not work on this server, as PHP4.3.2 is not
> > installed :-( (I
> > > already informed the hoster), but you can download the zip
> > and test it
> > > on your local machine.
> > >
> > > So please send your feedback and comments, so I can include this
> > > in PEAR as soon as possible :-)
> > >
> > > Best regards,
> > >
> > > Stephan